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

1197 lines
70 KiB

3 years ago
3 years ago
3 years ago
2 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
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
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
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
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
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
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
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
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
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
3 years ago
3 years ago
3 years ago
2 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 ICSWareHouseService
  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="TransCode"></param>
  27. /// <param name="TransSequence"></param>
  28. /// <param name="Quantity"></param>
  29. /// <param name="WorkPoint"></param>
  30. /// <param name="cmd"></param>
  31. public static void OneStepTransferDocIn(string TransCode,string TransSequence, string WorkPoint,string Quantity, SqlCommand cmd, Dictionary<string, string> language)
  32. {
  33. try
  34. {
  35. string sql = @"UPDATE ICSTransfer SET TransferQuantity=ISNULL(TransferQuantity,0)+'{2}'
  36. WHERE TransferNO='{0}' AND Sequence='{3}' AND WorkPoint='{1}' AND Type='1'
  37. IF EXISTS(SELECT a.ID FROM ICSTransfer a
  38. WHERE a.TransferNO='{0}' AND a.Sequence='{3}' and a.WorkPoint='{1}' AND a.Type='1' AND a.TransferQuantity<a.TransferQuantity)
  39. BEGIN
  40. RAISERROR('" + language.GetNameByCode("WMSAPIInfo144") + @"',16,1);
  41. RETURN
  42. END";
  43. sql = string.Format(sql, TransCode, WorkPoint, Quantity, TransSequence);
  44. if (!DBHelper.ExecuteNonQuery(sql, cmd))
  45. {
  46. throw new Exception(language.GetNameByCode("WMSAPIInfo145"));//"调拨单信息更新失败!");
  47. }
  48. }
  49. catch (Exception)
  50. {
  51. throw;
  52. }
  53. }
  54. #region 一步调拨(调拨申请单)
  55. /// <summary>
  56. /// 一步调拨(调拨申请单)
  57. /// </summary>
  58. /// <param name="TransCode"></param>
  59. /// <param name="TransSequence"></param>
  60. /// <param name="Quantity"></param>
  61. /// <param name="WorkPoint"></param>
  62. /// <param name="cmd"></param>
  63. public static void OneStepTransferApplicationIn(string TransCode, string TransSequence, string WorkPoint, string Quantity, SqlCommand cmd, Dictionary<string, string> language)
  64. {
  65. try
  66. {
  67. string sql = @"UPDATE ICSTransferApplication SET TransferQuantity=ISNULL(TransferQuantity,0)+'{2}'
  68. WHERE TransferNO='{0}' AND Sequence='{3}' AND WorkPoint='{1}' AND Type='1'
  69. IF EXISTS(SELECT a.ID FROM ICSTransferApplication a
  70. WHERE a.TransferNO='{0}' AND a.Sequence='{3}' and a.WorkPoint='{1}' AND a.Type='1' AND a.TransferQuantity<a.TransferQuantity)
  71. BEGIN
  72. RAISERROR('" + language.GetNameByCode("WMSAPIInfo144") + @"',16,1);
  73. RETURN
  74. END";
  75. sql = string.Format(sql, TransCode, WorkPoint, Quantity, TransSequence);
  76. if (!DBHelper.ExecuteNonQuery(sql, cmd))
  77. {
  78. throw new Exception(language.GetNameByCode("WMSAPIInfo145"));//"调拨单信息更新失败!");
  79. }
  80. }
  81. catch (Exception)
  82. {
  83. throw;
  84. }
  85. }
  86. /// <summary>
  87. /// 一步调拨接口
  88. /// </summary>
  89. /// <param name="TransType"></param>
  90. /// <param name="Identification"></param>
  91. /// <param name="cmd"></param>
  92. public static void OneStepTransferDocInERP(string TransType, string Identification, SqlCommand cmd, Dictionary<string, string> language,string BusinessCode)
  93. {
  94. try
  95. {
  96. #region ERP开立状态单据审核
  97. //检验调拨单是否一次性发完
  98. string sql = @"IF EXISTS(SELECT b.ID FROM ICSTransfer b
  99. WHERE b.TransferNO+b.WorkPoint IN (SELECT a.TransCode+a.WorkPoint FROM ICSWareHouseLotInfoLog a WHERE a.Identification='{0}')
  100. AND b.Type = '1' AND b.Quantity!=b.TransferQuantity)
  101. BEGIN
  102. RAISERROR('" + language.GetNameByCode("WMSAPIInfo097") + @"',16,1);
  103. RETURN
  104. END
  105. SELECT b.TransferID AS ID,a.MUSER AS [User],SYSDATETIME() AS MTime,con.Enable AS UpdateTodoQuantity,conStock.Enable AS UpdateStock,a.WorkPoint
  106. FROM ICSWareHouseLotInfoLog a
  107. INNER JOIN ICSTransfer b ON a.TransCode=b.TransferNO AND a.TransSequence=b.Sequence AND a.WorkPoint=b.WorkPoint
  108. INNER JOIN ICSConfiguration con ON con.Code='Stock003' AND a.WorkPoint=con.WorkPoint
  109. INNER JOIN ICSConfiguration conStock ON conStock.Code='UpdateStock006' AND a.WorkPoint=conStock.WorkPoint
  110. WHERE a.Identification='{0}' AND ERPUpload='0' AND b.Type='1'
  111. GROUP BY b.TransferID,a.MUSER,con.Enable,conStock.Enable,a.WorkPoint";
  112. sql = string.Format(sql, Identification);
  113. DataTable dt = DBHelper.SQlReturnData(sql, cmd);
  114. string Inputstr =JsonConvert.SerializeObject(dt);
  115. string resultStr = HTTPHelper.HttpPost(TransType, ERPUrl.OneStepTransferDocInURL, Inputstr);
  116. Result result = new Result();
  117. result = JsonConvert.DeserializeObject<Result>(resultStr);
  118. if (result.Success)
  119. {
  120. try
  121. {
  122. foreach (DataRow dr in dt.Rows)
  123. {
  124. ICSWareHouseLotInfoService.WareHouseLotInfoLogUpdate(TransType, dr["ID"].ToString(), Identification, "", "", "", "","", cmd, language, BusinessCode);
  125. }
  126. }
  127. catch (Exception ex)
  128. {
  129. log.Debug(ex.ToString());
  130. log.Debug(resultStr);
  131. }
  132. }
  133. else
  134. {
  135. throw new Exception(language.GetNameByCode("WMSAPIInfo080")+result.Message);
  136. }
  137. #endregion
  138. }
  139. catch (Exception)
  140. {
  141. throw;
  142. }
  143. }
  144. #endregion
  145. #region 调拨
  146. /// <summary>
  147. /// 调拨接口
  148. /// </summary>
  149. /// <param name="TransType"></param>
  150. /// <param name="Identification"></param>
  151. /// <param name="cmd"></param>
  152. public static void StepTransferDocInERP(string TransType, string Identification, SqlCommand cmd, Dictionary<string, string> language,string BusinessCode)
  153. {
  154. try
  155. {
  156. #region ERP开立状态单据审核
  157. //检验调拨单是否一次性发完
  158. string sql = @"SELECT a.ToWarehouseCode+a.MUSER+a.FromWarehouseCode AS Costre,a.ToWarehouseCode AS ToWHCode,a.FromWarehouseCode AS FromWHCode,a.MUSER,'' AS FromDepCode,'' AS ToDepCode,NULL AS TACode,ROW_NUMBER() OVER (ORDER BY a.ToWarehouseCode) AS Sequence,NULL AS TADetailID,
  159. a.InvCode,SUM(a.Quantity) AS Quantity,0 AS Amount,con.Enable AS UpdateTodoQuantity,conStock.Enable AS UpdateStock
  160. ,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,
  161. 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
  162. INTO #TempERP
  163. FROM ICSWareHouseLotInfoLog a
  164. INNER JOIN ICSInventoryLotDetail b ON a.LotNo=b.LotNo AND a.WorkPoint=b.WorkPoint
  165. INNER JOIN ICSInventoryLot lot ON a.LotNo=lot.LotNo AND a.WorkPoint=lot.WorkPoint
  166. INNER JOIN ICSExtension ext ON lot.ExtensionID=ext.ID AND lot.WorkPoint=ext.WorkPoint
  167. INNER JOIN ICSInventory inv ON a.InvCode=inv.InvCode AND a.WorkPoint=inv.WorkPoint
  168. LEFT JOIN ICSInventoryBatchEnable invBat ON a.InvCode=invBat.InvCode AND a.ToWarehouseCode=invBat.WHCode AND a.WorkPoint=invBat.WorkPoint
  169. INNER JOIN ICSConfiguration con ON con.Code='Stock003' AND a.WorkPoint=con.WorkPoint
  170. INNER JOIN ICSConfiguration conStock ON conStock.Code='UpdateStock006' AND a.WorkPoint=conStock.WorkPoint
  171. WHERE a.Identification='{0}' AND ERPUpload='0'
  172. GROUP BY a.ToWarehouseCode,a.MUSER,a.InvCode,conStock.Enable,con.Enable,a.FromWarehouseCode
  173. ,a.WorkPoint,ISNULL(ext.ProjectCode, ''),CASE WHEN (invBat.BatchEnable IS NULL AND ISNULL(inv.BatchEnable, '0')='1') OR ISNULL(invBat.BatchEnable, '0')='1' THEN ISNULL(ext.BatchCode, '') ELSE '' END,ISNULL(ext.Version, ''),ISNULL(ext.Brand, ''),
  174. ISNULL(ext.cFree1, ''),ISNULL(ext.cFree2, ''),ISNULL(ext.cFree3, ''),ISNULL(ext.cFree4, ''),ISNULL(ext.cFree5, ''),ISNULL(ext.cFree6, ''),ISNULL(ext.cFree7, ''),ISNULL(ext.cFree8, ''),ISNULL(ext.cFree9, ''),ISNULL(ext.cFree10, '')
  175. SELECT DISTINCT Costre,ToWHCode,FromWHCode,FromDepCode ,ToDepCode,MUSER AS [User],SYSDATETIME() AS MTime,UpdateTodoQuantity,WorkPoint,TACode,UpdateStock FROM #TempERP
  176. SELECT Costre,Sequence,InvCode,Quantity,Amount,TADetailID,ProjectCode,BatchCode,Version,Brand,cFree1,cFree2,cFree3,cFree4,cFree5,cFree6,cFree7,cFree8,cFree9,cFree10
  177. FROM #TempERP
  178. DROP TABLE #TempERP";
  179. sql = string.Format(sql, Identification);
  180. DataSet ds = DBHelper.SQlReturnDataSet(sql, cmd);
  181. string Inputstr = DataToJsonHelper.DataSetToJson(ds, "details", "Costre");
  182. string resultStr = HTTPHelper.HttpPost(TransType, ERPUrl.StepTransferDocInURL, Inputstr);
  183. Result result = new Result();
  184. result = JsonConvert.DeserializeObject<Result>(resultStr);
  185. if (result.Success)
  186. {
  187. try
  188. {
  189. JArray res = (JArray)JsonConvert.DeserializeObject(result.Data.ToString());
  190. foreach (var item in res)
  191. {
  192. JObject jo = (JObject)item;
  193. JArray resdetail = (JArray)JsonConvert.DeserializeObject(jo["details"].ToString());
  194. foreach (var detail in resdetail)
  195. {
  196. JObject det = (JObject)detail;
  197. 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()
  198. + det["cFree6"].ToString() + det["cFree7"].ToString() + det["cFree8"].ToString() + det["cFree9"].ToString() + det["cFree10"].ToString();
  199. ICSWareHouseLotInfoService.WareHouseLotInfoLogUpdate(TransType, det["DNDetailID"].ToString(), Identification, jo["ID"].ToString(), det["DetailID"].ToString(), jo["RCVTCode"].ToString(), det["Sequence"].ToString(),allcol, cmd, language, BusinessCode);
  200. }
  201. }
  202. }
  203. catch (Exception ex)
  204. {
  205. log.Debug(ex.ToString());
  206. log.Debug(resultStr);
  207. }
  208. }
  209. else
  210. {
  211. throw new Exception(language.GetNameByCode("WMSAPIInfo080") + result.Message);
  212. }
  213. #endregion
  214. }
  215. catch (Exception)
  216. {
  217. throw;
  218. }
  219. }
  220. #endregion
  221. #region 调拨申请单接口
  222. /// <summary>
  223. /// 调拨申请单接口
  224. /// </summary>
  225. /// <param name="TransType"></param>
  226. /// <param name="Identification"></param>
  227. /// <param name="cmd"></param>
  228. public static void StepTransferApplicationERP(string TransType, string Identification, SqlCommand cmd, Dictionary<string, string> language, string BusinessCode)
  229. {
  230. try
  231. {
  232. #region ERP开立状态单据审核
  233. //检验调拨单是否一次性发完
  234. string sql = @"SELECT c.TransferDetailID as TADetailID,a.ToWarehouseCode+a.MUSER+a.FromWarehouseCode AS Costre,a.ToWarehouseCode AS ToWHCode,a.FromWarehouseCode AS FromWHCode,a.MUSER,'' AS FromDepCode,'' AS ToDepCode,a.TransCode AS TACode,ROW_NUMBER() OVER (ORDER BY a.ToWarehouseCode) AS Sequence,
  235. a.InvCode,SUM(a.Quantity) AS Quantity,0 AS Amount,con.Enable AS UpdateTodoQuantity,conStock.Enable AS UpdateStock
  236. ,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,
  237. 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
  238. INTO #TempERP
  239. FROM ICSWareHouseLotInfoLog a
  240. INNER JOIN ICSTransfer c ON a.TransCode=c.TransferNO and a.TransSequence=c.Sequence and a.WorkPoint=c.WorkPoint
  241. --INNER JOIN ICSInventoryLotDetail b ON a.LotNo=b.LotNo AND a.WorkPoint=b.WorkPoint
  242. INNER JOIN ICSInventoryLot lot ON a.LotNo=lot.LotNo AND a.WorkPoint=lot.WorkPoint
  243. INNER JOIN ICSExtension ext ON lot.ExtensionID=ext.ID AND lot.WorkPoint=ext.WorkPoint
  244. INNER JOIN ICSInventory inv ON a.InvCode=inv.InvCode AND a.WorkPoint=inv.WorkPoint
  245. LEFT JOIN ICSInventoryBatchEnable invBat ON a.InvCode=invBat.InvCode AND a.ToWarehouseCode=invBat.WHCode AND a.WorkPoint=invBat.WorkPoint
  246. INNER JOIN ICSConfiguration con ON con.Code='Stock003' AND a.WorkPoint=con.WorkPoint
  247. INNER JOIN ICSConfiguration conStock ON conStock.Code='UpdateStock006' AND a.WorkPoint=conStock.WorkPoint
  248. WHERE a.Identification='{0}' AND ERPUpload='0'
  249. GROUP BY a.ToWarehouseCode,a.MUSER,c.TransferDetailID,a.InvCode,conStock.Enable,con.Enable,a.FromWarehouseCode
  250. ,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, ''),
  251. 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, ''),a.TransCode
  252. SELECT DISTINCT Costre,ToWHCode,FromWHCode,FromDepCode ,ToDepCode,MUSER AS [User],SYSDATETIME() AS MTime,UpdateTodoQuantity,WorkPoint,TACode,UpdateStock FROM #TempERP
  253. SELECT Costre,Sequence,InvCode,Quantity,Amount,TADetailID,ProjectCode,BatchCode,Version,Brand,cFree1,cFree2,cFree3,cFree4,cFree5,cFree6,cFree7,cFree8,cFree9,cFree10
  254. FROM #TempERP
  255. DROP TABLE #TempERP";
  256. sql = string.Format(sql, Identification);
  257. DataSet ds = DBHelper.SQlReturnDataSet(sql, cmd);
  258. string Inputstr = DataToJsonHelper.DataSetToJson(ds, "details", "Costre");
  259. string resultStr = HTTPHelper.HttpPost(TransType, ERPUrl.StepTransferApplicationURL, Inputstr);
  260. Result result = new Result();
  261. result = JsonConvert.DeserializeObject<Result>(resultStr);
  262. if (result.Success)
  263. {
  264. try
  265. {
  266. JArray res = (JArray)JsonConvert.DeserializeObject(result.Data.ToString());
  267. foreach (var item in res)
  268. {
  269. JObject jo = (JObject)item;
  270. JArray resdetail = (JArray)JsonConvert.DeserializeObject(jo["details"].ToString());
  271. foreach (var detail in resdetail)
  272. {
  273. JObject det = (JObject)detail;
  274. string allcol = "" + 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()
  275. + det["cFree6"].ToString() + det["cFree7"].ToString() + det["cFree8"].ToString() + det["cFree9"].ToString() + det["cFree10"].ToString();
  276. ICSWareHouseLotInfoService.WareHouseLotInfoLogUpdate(TransType, det["DNDetailID"].ToString(), Identification, jo["ID"].ToString(), det["DetailID"].ToString(), jo["RCVTCode"].ToString(), det["Sequence"].ToString(), allcol, cmd, language, BusinessCode);
  277. }
  278. }
  279. }
  280. catch (Exception ex)
  281. {
  282. log.Debug(ex.ToString());
  283. log.Debug(resultStr);
  284. }
  285. }
  286. else
  287. {
  288. throw new Exception(language.GetNameByCode("WMSAPIInfo080") + result.Message);
  289. }
  290. #endregion
  291. }
  292. catch (Exception)
  293. {
  294. throw;
  295. }
  296. }
  297. #endregion
  298. #region 两步调出
  299. /// <summary>
  300. /// 两步调出
  301. /// </summary>
  302. /// <param name="TransCode"></param>
  303. /// <param name="TransSequence"></param>
  304. /// <param name="Quantity"></param>
  305. /// <param name="WorkPoint"></param>
  306. /// <param name="cmd"></param>
  307. public static void TwoStepTransferDocOut(string TransCode, string TransSequence, string Quantity, string WorkPoint, SqlCommand cmd, Dictionary<string, string> language)
  308. {
  309. try
  310. {
  311. string sql = @"DECLARE @Status VARCHAR(10)
  312. SELECT @Status=a.Status FROM ICSOtherOut a
  313. INNER JOIN ICSTransfer b ON a.TransferDetailID=b.TransferDetailID AND a.WorkPoint=b.WorkPoint
  314. WHERE a.OutCode='{0}' AND a.Sequence='{3}' AND a.WorkPoint='{1}'
  315. IF (@Status IS NULL)
  316. BEGIN
  317. RAISERROR('" + language.GetNameByCode("WMSAPIInfo146") + @"',16,1);
  318. RETURN
  319. END
  320. ELSE IF (@Status!='1')
  321. BEGIN
  322. RAISERROR('" + language.GetNameByCode("WMSAPIInfo147") + @"',16,1);
  323. RETURN
  324. END
  325. UPDATE a SET OutQuantity=ISNULL(OutQuantity,0)+'{2}'
  326. FROM ICSOtherOut a
  327. INNER JOIN ICSTransfer b ON a.TransferDetailID=b.TransferDetailID AND a.WorkPoint=b.WorkPoint
  328. WHERE a.OutCode='{0}' AND a.Sequence='{3}' AND a.WorkPoint='{1}'
  329. IF EXISTS(SELECT a.ID FROM ICSOtherOut a
  330. INNER JOIN ICSTransfer b ON a.TransferDetailID=b.TransferDetailID AND a.WorkPoint=b.WorkPoint
  331. WHERE a.OutCode='{0}' AND a.Sequence='{3}' and a.WorkPoint='{1}' AND a.Quantity<a.OutQuantity)
  332. BEGIN
  333. RAISERROR('" + language.GetNameByCode("WMSAPIInfo091") + @"',16,1);
  334. RETURN
  335. END";
  336. sql = string.Format(sql, TransCode, WorkPoint, Quantity, TransSequence);
  337. if (!DBHelper.ExecuteNonQuery(sql, cmd))
  338. {
  339. throw new Exception(language.GetNameByCode("WMSAPIInfo148"));//"两步调出单更新失败!");
  340. }
  341. }
  342. catch (Exception)
  343. {
  344. throw;
  345. }
  346. }
  347. /// <summary>
  348. /// 两步调出接口
  349. /// </summary>
  350. /// <param name="TransType"></param>
  351. /// <param name="Identification"></param>
  352. /// <param name="cmd"></param>
  353. public static void TwoStepTransferDocOutERP(string TransType, string Identification, SqlCommand cmd, Dictionary<string, string> language,string BusinessCode)
  354. {
  355. try
  356. {
  357. #region ERP开立状态单据审核
  358. string sql = @"IF EXISTS(SELECT b.ID FROM ICSOtherOut b
  359. INNER JOIN ICSTransfer c ON b.TransferDetailID=c.TransferDetailID AND b.WorkPoint=c.WorkPoint
  360. WHERE b.OutCode+b.WorkPoint IN (SELECT a.TransCode+a.WorkPoint FROM ICSWareHouseLotInfoLog a WHERE a.Identification='{0}')
  361. AND b.Quantity!=b.OutQuantity)
  362. BEGIN
  363. RAISERROR('" + language.GetNameByCode("WMSAPIInfo098") + @"',16,1);
  364. RETURN
  365. END
  366. SELECT b.OutID AS ID,a.MUSER AS [User],SYSDATETIME() AS MTime,con.Enable AS UpdateTodoQuantity,conStock.Enable AS UpdateStock,a.WorkPoint
  367. FROM ICSWareHouseLotInfoLog a
  368. INNER JOIN ICSOtherOut b ON a.TransCode=b.OutCode AND a.TransSequence=b.Sequence AND a.WorkPoint=b.WorkPoint
  369. INNER JOIN ICSTransfer c ON b.TransferDetailID=c.TransferDetailID AND b.WorkPoint=c.WorkPoint
  370. INNER JOIN ICSConfiguration con ON con.Code='Stock002' AND a.WorkPoint=con.WorkPoint
  371. INNER JOIN ICSConfiguration conStock ON conStock.Code='UpdateStock003' AND a.WorkPoint=conStock.WorkPoint
  372. WHERE a.Identification='{0}' AND ERPUpload='0' AND a.BusinessCode = '22'
  373. GROUP BY b.OutID,a.MUSER,con.Enable,conStock.Enable,a.WorkPoint";
  374. sql = string.Format(sql, Identification);
  375. DataTable dt = DBHelper.SQlReturnData(sql, cmd);
  376. string Inputstr = JsonConvert.SerializeObject(dt);
  377. string resultStr = HTTPHelper.HttpPost(TransType, ERPUrl.TwoStepTransferDocOutURL, Inputstr);
  378. Result result = new Result();
  379. result = JsonConvert.DeserializeObject<Result>(resultStr);
  380. if (result.Success)
  381. {
  382. try
  383. {
  384. foreach (DataRow dr in dt.Rows)
  385. {
  386. ICSWareHouseLotInfoService.WareHouseLotInfoLogUpdate(TransType, dr["ID"].ToString(), Identification, "", "", "", "", "", cmd, language, BusinessCode);
  387. }
  388. }
  389. catch (Exception ex)
  390. {
  391. log.Debug(ex.ToString());
  392. log.Debug(resultStr);
  393. }
  394. }
  395. else
  396. {
  397. throw new Exception(language.GetNameByCode("WMSAPIInfo080")+result.Message);
  398. }
  399. #endregion
  400. }
  401. catch (Exception)
  402. {
  403. throw;
  404. }
  405. }
  406. #endregion
  407. #region 两步调入
  408. /// <summary>
  409. /// 两步调入
  410. /// </summary>
  411. /// <param name="TransCode"></param>
  412. /// <param name="TransSequence"></param>
  413. /// <param name="Quantity"></param>
  414. /// <param name="WorkPoint"></param>
  415. /// <param name="cmd"></param>
  416. public static void TwoStepTransferDocIn(string TransCode, string TransSequence, string LotNo, string Quantity, string WorkPoint, SqlCommand cmd, Dictionary<string, string> language)
  417. {
  418. //需要关联其他入库单
  419. try
  420. {
  421. string sql = @"DECLARE @Status VARCHAR(10)
  422. SELECT @Status=Otin.Status FROM ICSOtherIn Otin
  423. INNER JOIN ICSTransfer tra ON Otin.TransferDetailID=tra.TransferDetailID AND Otin.WorkPoint=tra.WorkPoint
  424. INNER JOIN ICSOtherOut out ON out.TransferDetailID=tra.TransferDetailID AND out.WorkPoint=tra.WorkPoint
  425. INNER JOIN ICSWareHouseLotInfoLog log ON out.OutCode=log.TransCode AND out.Sequence=log.TransSequence AND out.WorkPoint=log.WorkPoint
  426. INNER JOIN ICSWareHouseLotInfo a ON a.LotNo=log.LotNo AND a.WorkPoint=log.WorkPoint
  427. WHERE a.LotNo='{0}' AND a.WorkPoint='{1}' AND Otin.InCode='{2}' AND Otin.Sequence='{3}'
  428. IF (@Status IS NULL)
  429. BEGIN
  430. RAISERROR('" + language.GetNameByCode("WMSAPIInfo081") + @"',16,1);
  431. RETURN
  432. END
  433. ELSE IF (@Status!='1')
  434. BEGIN
  435. RAISERROR('" + language.GetNameByCode("WMSAPIInfo137") + @"',16,1);
  436. RETURN
  437. END
  438. UPDATE Otin SET InQuantity=ISNULL(InQuantity,0)+'{4}'
  439. FROM ICSOtherIn Otin
  440. INNER JOIN ICSTransfer tra ON Otin.TransferDetailID=tra.TransferDetailID AND Otin.WorkPoint=tra.WorkPoint
  441. INNER JOIN ICSOtherOut out ON out.TransferDetailID=tra.TransferDetailID AND out.WorkPoint=tra.WorkPoint
  442. INNER JOIN ICSWareHouseLotInfoLog log ON out.OutCode=log.TransCode AND out.Sequence=log.TransSequence AND out.WorkPoint=log.WorkPoint
  443. INNER JOIN ICSWareHouseLotInfo a ON a.LotNo=log.LotNo AND a.WorkPoint=log.WorkPoint
  444. WHERE a.LotNo='{0}' AND a.WorkPoint='{1}' AND Otin.InCode='{2}' AND Otin.Sequence='{3}'
  445. IF EXISTS(SELECT a.LotNo FROM ICSOtherIn Otin
  446. INNER JOIN ICSTransfer tra ON Otin.TransferDetailID=tra.TransferDetailID AND Otin.WorkPoint=tra.WorkPoint
  447. INNER JOIN ICSOtherOut out ON out.TransferDetailID=tra.TransferDetailID AND out.WorkPoint=tra.WorkPoint
  448. INNER JOIN ICSWareHouseLotInfoLog log ON out.OutCode=log.TransCode AND out.Sequence=log.TransSequence AND out.WorkPoint=log.WorkPoint
  449. INNER JOIN ICSWareHouseLotInfo a ON a.LotNo=log.LotNo AND a.WorkPoint=log.WorkPoint
  450. WHERE a.LotNo='{0}' AND a.WorkPoint='{1}' AND Otin.InCode='{2}' AND Otin.Sequence='{3}' AND Otin.Quantity<Otin.InQuantity)
  451. BEGIN
  452. RAISERROR('" + language.GetNameByCode("WMSAPIInfo149") + @"',16,1);
  453. END";
  454. sql = string.Format(sql, LotNo, WorkPoint,TransCode,TransSequence, Quantity);
  455. if (!DBHelper.ExecuteNonQuery(sql, cmd))
  456. {
  457. throw new Exception(language.GetNameByCode("WMSAPIInfo150"));//"两步调入单更新失败!");
  458. }
  459. }
  460. catch (Exception)
  461. {
  462. throw;
  463. }
  464. }
  465. /// <summary>
  466. /// 两步调入接口
  467. /// </summary>
  468. /// <param name="TransType"></param>
  469. /// <param name="Identification"></param>
  470. /// <param name="cmd"></param>
  471. public static void TwoStepTransferDocInERP(string TransType, string Identification, SqlCommand cmd, Dictionary<string, string> language,string BusinessCode)
  472. {
  473. try
  474. {
  475. #region ERP开立状态单据审核
  476. string sql = @"IF EXISTS(SELECT b.ID FROM ICSOtherIn b
  477. INNER JOIN ICSTransfer c ON b.TransferDetailID=c.TransferDetailID AND b.WorkPoint=c.WorkPoint
  478. WHERE b.InCode+b.WorkPoint IN (SELECT a.TransCode+a.WorkPoint FROM ICSWareHouseLotInfoLog a WHERE a.Identification='{0}')
  479. AND b.Quantity!=b.InQuantity)
  480. BEGIN
  481. RAISERROR('" + language.GetNameByCode("WMSAPIInfo099") + @"',16,1);
  482. RETURN
  483. END
  484. SELECT b.InID AS ID,a.MUSER AS [User],SYSDATETIME() AS MTime,con.Enable AS UpdateTodoQuantity,conStock.Enable AS UpdateStock,a.WorkPoint
  485. FROM ICSWareHouseLotInfoLog a
  486. INNER JOIN ICSOtherIn b ON a.TransCode=b.InCode AND a.TransSequence=b.Sequence AND a.WorkPoint=b.WorkPoint
  487. INNER JOIN ICSTransfer c ON b.TransferDetailID=c.TransferDetailID AND b.WorkPoint=c.WorkPoint
  488. INNER JOIN ICSConfiguration con ON con.Code='Stock001' AND a.WorkPoint=con.WorkPoint
  489. INNER JOIN ICSConfiguration conStock ON conStock.Code='UpdateStock003' AND a.WorkPoint=conStock.WorkPoint
  490. WHERE a.Identification='{0}' AND ERPUpload='0'
  491. GROUP BY b.InID,a.MUSER,con.Enable,conStock.Enable,a.WorkPoint";
  492. sql = string.Format(sql, Identification);
  493. DataTable dt = DBHelper.SQlReturnData(sql, cmd);
  494. string Inputstr = JsonConvert.SerializeObject(dt);
  495. string resultStr = HTTPHelper.HttpPost(TransType, ERPUrl.TwoStepTransferDocInURL, Inputstr);
  496. Result result = new Result();
  497. result = JsonConvert.DeserializeObject<Result>(resultStr);
  498. if (result.Success)
  499. {
  500. try
  501. {
  502. foreach (DataRow dr in dt.Rows)
  503. {
  504. ICSWareHouseLotInfoService.WareHouseLotInfoLogUpdate(TransType, dr["ID"].ToString(), Identification, "", "", "", "","", cmd, language, BusinessCode);
  505. }
  506. }
  507. catch (Exception ex)
  508. {
  509. log.Debug(ex.ToString());
  510. log.Debug(resultStr);
  511. }
  512. }
  513. else
  514. {
  515. throw new Exception(language.GetNameByCode("WMSAPIInfo080")+result.Message);
  516. }
  517. #endregion
  518. }
  519. catch (Exception)
  520. {
  521. throw;
  522. }
  523. }
  524. #endregion
  525. #region 其他出库
  526. /// <summary>
  527. /// 其他出库
  528. /// </summary>
  529. /// <param name="TransCode"></param>
  530. /// <param name="TransSequence"></param>
  531. /// <param name="Quantity"></param>
  532. /// <param name="WorkPoint"></param>
  533. /// <param name="cmd"></param>
  534. public static void OtherOutDoc(string TransCode, string TransSequence, string Quantity, string WorkPoint, SqlCommand cmd, Dictionary<string, string> language)
  535. {
  536. try
  537. {
  538. string sql = @"DECLARE @Status VARCHAR(10)
  539. SELECT @Status=a.Status FROM ICSOtherOut a
  540. WHERE a.OutCode='{0}' AND a.Sequence='{3}' AND a.WorkPoint='{1}'
  541. IF (@Status IS NULL)
  542. BEGIN
  543. RAISERROR('" + language.GetNameByCode("WMSAPIInfo151") + @"',16,1);
  544. RETURN
  545. END
  546. ELSE IF (@Status!='1')
  547. BEGIN
  548. RAISERROR('" + language.GetNameByCode("WMSAPIInfo152") + @"',16,1);
  549. RETURN
  550. END
  551. UPDATE a SET OutQuantity=ISNULL(OutQuantity,0)+'{2}'
  552. FROM ICSOtherOut a
  553. WHERE a.OutCode='{0}' AND a.Sequence='{3}' AND a.WorkPoint='{1}'
  554. IF EXISTS(SELECT a.ID FROM ICSOtherOut a
  555. WHERE a.OutCode='{0}' AND a.Sequence='{3}' and a.WorkPoint='{1}' AND a.Quantity<a.OutQuantity)
  556. BEGIN
  557. RAISERROR('" + language.GetNameByCode("WMSAPIInfo091") + @"',16,1);
  558. RETURN
  559. END";
  560. sql = string.Format(sql, TransCode, WorkPoint, Quantity, TransSequence);
  561. if (!DBHelper.ExecuteNonQuery(sql, cmd))
  562. {
  563. throw new Exception(language.GetNameByCode("WMSAPIInfo153"));//"其他出库单更新失败!");
  564. }
  565. }
  566. catch (Exception)
  567. {
  568. throw;
  569. }
  570. }
  571. /// <summary>
  572. /// 其他出库接口
  573. /// </summary>
  574. /// <param name="TransType"></param>
  575. /// <param name="Identification"></param>
  576. /// <param name="cmd"></param>
  577. public static void OtherOutDocERP(string TransType, string Identification, SqlCommand cmd, Dictionary<string, string> language,string BusinessCode)
  578. {
  579. try
  580. {
  581. #region ERP开立状态单据审核
  582. string sql = @"IF EXISTS(SELECT b.ID FROM ICSOtherOut b
  583. WHERE b.OutCode+b.WorkPoint IN (SELECT a.TransCode+a.WorkPoint FROM ICSWareHouseLotInfoLog a WHERE a.Identification='{0}')
  584. AND b.Quantity!=b.OutQuantity)
  585. BEGIN
  586. RAISERROR('" + language.GetNameByCode("WMSAPIInfo100") + @"',16,1);
  587. RETURN
  588. END
  589. SELECT b.OutID AS ID,a.MUSER AS [User],SYSDATETIME() AS MTime,con.Enable AS UpdateTodoQuantity,conStock.Enable AS UpdateStock,a.WorkPoint
  590. FROM ICSWareHouseLotInfoLog a
  591. INNER JOIN ICSOtherOut b ON a.TransCode=b.OutCode AND a.TransSequence=b.Sequence AND a.WorkPoint=b.WorkPoint
  592. INNER JOIN ICSConfiguration con ON con.Code='Stock002' AND a.WorkPoint=con.WorkPoint
  593. INNER JOIN ICSConfiguration conStock ON conStock.Code='UpdateStock003' AND a.WorkPoint=conStock.WorkPoint
  594. WHERE a.Identification='{0}' AND ERPUpload='0' AND a.BusinessCode = '24'
  595. GROUP BY b.OutID,a.MUSER,con.Enable,conStock.Enable,a.WorkPoint";
  596. sql = string.Format(sql, Identification);
  597. DataTable dt = DBHelper.SQlReturnData(sql, cmd);
  598. string Inputstr = JsonConvert.SerializeObject(dt);
  599. string resultStr = HTTPHelper.HttpPost(TransType, ERPUrl.OtherOutDocURL, Inputstr);
  600. Result result = new Result();
  601. result = JsonConvert.DeserializeObject<Result>(resultStr);
  602. if (result.Success)
  603. {
  604. try
  605. {
  606. foreach (DataRow dr in dt.Rows)
  607. {
  608. ICSWareHouseLotInfoService.WareHouseLotInfoLogUpdate(TransType, dr["ID"].ToString(), Identification, "", "", "", "","", cmd, language, BusinessCode);
  609. }
  610. }
  611. catch (Exception ex)
  612. {
  613. log.Debug(ex.ToString());
  614. log.Debug(resultStr);
  615. }
  616. }
  617. else
  618. {
  619. throw new Exception(language.GetNameByCode("WMSAPIInfo080")+result.Message);
  620. }
  621. #endregion
  622. }
  623. catch (Exception)
  624. {
  625. throw;
  626. }
  627. }
  628. #endregion
  629. #region 其他入库
  630. /// <summary>
  631. /// 其他入库
  632. /// </summary>
  633. /// <param name="TransCode"></param>
  634. /// <param name="TransSequence"></param>
  635. /// <param name="Quantity"></param>
  636. /// <param name="WorkPoint"></param>
  637. /// <param name="cmd"></param>
  638. public static void OtherInDoc(string LotNo, string Quantity, string WorkPoint, SqlCommand cmd, Dictionary<string, string> language)
  639. {
  640. try
  641. {
  642. string sql = @"DECLARE @Status VARCHAR(10)
  643. SELECT @Status=c.Status FROM ICSInventoryLot a
  644. INNER JOIN ICSInventoryLotDetail b ON a.LotNo=b.LotNo AND a.WorkPoint=b.WorkPoint
  645. INNER JOIN ICSOtherIn c ON b.TransCode=c.InCode AND b.TransSequence=c.Sequence AND b.WorkPoint=c.WorkPoint
  646. WHERE a.LotNo='{0}' AND a.WorkPoint='{1}'
  647. IF (@Status IS NULL)
  648. BEGIN
  649. RAISERROR('" + language.GetNameByCode("WMSAPIInfo081") + @"',16,1);
  650. RETURN
  651. END
  652. ELSE IF (@Status!='1')
  653. BEGIN
  654. RAISERROR('" + language.GetNameByCode("WMSAPIInfo137") + @"',16,1);
  655. RETURN
  656. END
  657. UPDATE c SET InQuantity=ISNULL(InQuantity,0)+'{2}'
  658. FROM ICSInventoryLot a
  659. INNER JOIN ICSInventoryLotDetail b ON a.LotNo=b.LotNo AND a.WorkPoint=b.WorkPoint
  660. INNER JOIN ICSOtherIn c ON b.TransCode=c.InCode AND b.TransSequence=c.Sequence AND b.WorkPoint=c.WorkPoint
  661. WHERE a.LotNo='{0}' AND a.WorkPoint='{1}'
  662. IF EXISTS(SELECT a.LotNo FROM ICSInventoryLot a
  663. INNER JOIN ICSInventoryLotDetail b ON a.LotNo=b.LotNo AND a.WorkPoint=b.WorkPoint
  664. INNER JOIN ICSOtherIn c ON b.TransCode=c.InCode AND b.TransSequence=c.Sequence AND b.WorkPoint=c.WorkPoint
  665. WHERE a.LotNo='{0}' AND a.WorkPoint='{1}' AND c.Quantity<c.InQuantity)
  666. BEGIN
  667. RAISERROR('" + language.GetNameByCode("WMSAPIInfo154") + @"',16,1);
  668. END";
  669. sql = string.Format(sql, LotNo, WorkPoint, Quantity);
  670. if (!DBHelper.ExecuteNonQuery(sql, cmd))
  671. {
  672. throw new Exception(language.GetNameByCode("WMSAPIInfo155"));//"其他入库单更新失败!");
  673. }
  674. }
  675. catch (Exception)
  676. {
  677. throw;
  678. }
  679. }
  680. /// <summary>
  681. /// 其他入库接口
  682. /// </summary>
  683. /// <param name="TransType"></param>
  684. /// <param name="Identification"></param>
  685. /// <param name="cmd"></param>
  686. public static void OtherInDocERP(string TransType, string Identification, SqlCommand cmd, Dictionary<string, string> language,string BusinessCode)
  687. {
  688. try
  689. {
  690. #region ERP开立状态单据审核
  691. string sql = @"IF EXISTS(SELECT b.ID FROM ICSOtherIn b
  692. WHERE b.InCode+b.WorkPoint IN (SELECT a.TransCode+a.WorkPoint FROM ICSWareHouseLotInfoLog a WHERE a.Identification='{0}')
  693. AND b.Quantity!=b.InQuantity)
  694. BEGIN
  695. RAISERROR('" + language.GetNameByCode("WMSAPIInfo101") + @"',16,1);
  696. RETURN
  697. END
  698. SELECT b.InID AS ID,a.MUSER AS [User],SYSDATETIME() AS MTime,con.Enable AS UpdateTodoQuantity,conStock.Enable AS UpdateStock,a.WorkPoint
  699. FROM ICSWareHouseLotInfoLog a
  700. INNER JOIN ICSOtherIn b ON a.TransCode=b.InCode AND a.TransSequence=b.Sequence AND a.WorkPoint=b.WorkPoint
  701. INNER JOIN ICSConfiguration con ON con.Code='Stock001' AND a.WorkPoint=con.WorkPoint
  702. INNER JOIN ICSConfiguration conStock ON conStock.Code='UpdateStock003' AND a.WorkPoint=conStock.WorkPoint
  703. WHERE a.Identification='{0}' AND ERPUpload='0'
  704. GROUP BY b.InID,a.MUSER,con.Enable,conStock.Enable,a.WorkPoint";
  705. sql = string.Format(sql, Identification);
  706. DataTable dt = DBHelper.SQlReturnData(sql, cmd);
  707. string Inputstr = JsonConvert.SerializeObject(dt);
  708. string resultStr = HTTPHelper.HttpPost(TransType, ERPUrl.OtherInDocURL, Inputstr);
  709. Result result = new Result();
  710. result = JsonConvert.DeserializeObject<Result>(resultStr);
  711. if (result.Success)
  712. {
  713. try
  714. {
  715. foreach (DataRow dr in dt.Rows)
  716. {
  717. ICSWareHouseLotInfoService.WareHouseLotInfoLogUpdate(TransType, dr["ID"].ToString(), Identification, "", "", "", "","", cmd, language, BusinessCode);
  718. }
  719. }
  720. catch (Exception ex)
  721. {
  722. log.Debug(ex.ToString());
  723. log.Debug(resultStr);
  724. }
  725. }
  726. else
  727. {
  728. throw new Exception(language.GetNameByCode("WMSAPIInfo080")+result.Message);
  729. }
  730. #endregion
  731. }
  732. catch (Exception)
  733. {
  734. throw;
  735. }
  736. }
  737. #endregion
  738. #region 拆卸单
  739. /// <summary>
  740. /// 拆卸单
  741. /// </summary>
  742. /// <param name="TransCode"></param>
  743. /// <param name="TransSequence"></param>
  744. /// <param name="Quantity"></param>
  745. /// <param name="WorkPoint"></param>
  746. /// <param name="cmd"></param>
  747. public static void DisassemblyDoc(string LotNo, string Quantity, string WorkPoint, SqlCommand cmd, Dictionary<string, string> language)
  748. {
  749. try
  750. {
  751. string sql = @"DECLARE @Status VARCHAR(10)
  752. SELECT @Status=c.Status FROM ICSInventoryLot a
  753. INNER JOIN ICSInventoryLotDetail b ON a.LotNo=b.LotNo AND a.WorkPoint=b.WorkPoint
  754. INNER JOIN ICSDisassemblyDoc c ON b.TransCode=c.DABDOCCode AND b.TransSequence=c.Sequence AND b.WorkPoint=c.WorkPoint
  755. WHERE a.LotNo='{0}' AND a.WorkPoint='{1}' AND c.DABDOCType='2'
  756. IF (@Status IS NULL)
  757. BEGIN
  758. RAISERROR('" + language.GetNameByCode("WMSAPIInfo081") + @"',16,1);
  759. RETURN
  760. END
  761. ELSE IF (@Status!='1')
  762. BEGIN
  763. RAISERROR('" + language.GetNameByCode("WMSAPIInfo137") + @"',16,1);
  764. RETURN
  765. END
  766. UPDATE c SET DABDOCQuantity=ISNULL(DABDOCQuantity,0)+'{2}'
  767. FROM ICSInventoryLot a
  768. INNER JOIN ICSInventoryLotDetail b ON a.LotNo=b.LotNo AND a.WorkPoint=b.WorkPoint
  769. INNER JOIN ICSDisassemblyDoc c ON b.TransCode=c.DABDOCCode AND b.TransSequence=c.Sequence AND b.WorkPoint=c.WorkPoint
  770. WHERE a.LotNo='{0}' AND a.WorkPoint='{1}'
  771. IF EXISTS(SELECT a.LotNo FROM ICSInventoryLot a
  772. INNER JOIN ICSInventoryLotDetail b ON a.LotNo=b.LotNo AND a.WorkPoint=b.WorkPoint
  773. INNER JOIN ICSDisassemblyDoc c ON b.TransCode=c.DABDOCCode AND b.TransSequence=c.Sequence AND b.WorkPoint=c.WorkPoint
  774. WHERE a.LotNo='{0}' AND a.WorkPoint='{1}' AND c.Quantity<c.DABDOCQuantity)
  775. BEGIN
  776. RAISERROR('" + language.GetNameByCode("WMSAPIInfo156") + @"',16,1);
  777. END";
  778. sql = string.Format(sql, LotNo, WorkPoint, Quantity);
  779. if (!DBHelper.ExecuteNonQuery(sql, cmd))
  780. {
  781. throw new Exception(language.GetNameByCode("WMSAPIInfo157"));//"拆卸单更新失败!");
  782. }
  783. }
  784. catch (Exception)
  785. {
  786. throw;
  787. }
  788. }
  789. /// <summary>
  790. /// 拆卸单更新套件锁定数量
  791. /// </summary>
  792. /// <param name="Identification"></param>
  793. /// <param name="cmd"></param>
  794. public static void DisassemblyDoc(string Identification, SqlCommand cmd, Dictionary<string, string> language)
  795. {
  796. try
  797. {
  798. string sql = @"UPDATE ICSDisassemblyDoc SET DABDOCQuantity=Quantity
  799. WHERE DABDOCCode+Sequence+WorkPoint IN(SELECT DISTINCT d.TransCode+d.TransSequence+d.WorkPoint
  800. FROM ICSWareHouseLotInfoLog a
  801. INNER JOIN ICSInventoryLotDetail b ON a.LotNo=b.LotNo AND a.WorkPoint=b.WorkPoint
  802. INNER JOIN ICSDisassemblyDoc c ON b.TransCode=c.DABDOCCode AND b.TransSequence=c.Sequence AND b.WorkPoint=c.WorkPoint
  803. INNER JOIN ICSWareHouseLotInfoLog d ON b.TransCode=d.TransCode AND d.TransSequence='1' AND b.WorkPoint=d.WorkPoint
  804. WHERE a.Identification='{0}' AND d.ERPUpload='0' AND d.Lock='1')
  805. UPDATE ICSWareHouseLotInfo SET Quantity=Quantity-LockQuantity,LockQuantity=0
  806. WHERE LotNo+WorkPoint IN(SELECT DISTINCT d.LotNo+d.WorkPoint
  807. FROM ICSWareHouseLotInfoLog a
  808. INNER JOIN ICSInventoryLotDetail b ON a.LotNo=b.LotNo AND a.WorkPoint=b.WorkPoint
  809. INNER JOIN ICSDisassemblyDoc c ON b.TransCode=c.DABDOCCode AND b.TransSequence=c.Sequence AND b.WorkPoint=c.WorkPoint
  810. INNER JOIN ICSWareHouseLotInfoLog d ON b.TransCode=d.TransCode AND d.TransSequence='1' AND b.WorkPoint=d.WorkPoint
  811. WHERE a.Identification='{0}' AND d.ERPUpload='0' AND d.Lock='1')";
  812. sql = string.Format(sql, Identification);
  813. if (!DBHelper.ExecuteNonQuery(sql, cmd))
  814. {
  815. throw new Exception(language.GetNameByCode("WMSAPIInfo158"));//"拆卸单套件更新失败!");
  816. }
  817. }
  818. catch (Exception)
  819. {
  820. throw;
  821. }
  822. }
  823. /// <summary>
  824. /// 拆卸单接口
  825. /// </summary>
  826. /// <param name="TransType"></param>
  827. /// <param name="Identification"></param>
  828. /// <param name="cmd"></param>
  829. public static void DisassemblyDocERP(string TransType, string Identification, SqlCommand cmd, Dictionary<string, string> language,string BusinessCode)
  830. {
  831. try
  832. {
  833. #region ERP开立状态单据审核
  834. string sql = @"IF EXISTS(SELECT b.ID FROM ICSDisassemblyDoc b
  835. WHERE b.DABDOCCode+b.WorkPoint IN (SELECT a.TransCode+a.WorkPoint FROM ICSWareHouseLotInfoLog a WHERE a.Identification='{0}')
  836. AND b.Quantity!=b.DABDOCQuantity)
  837. BEGIN
  838. RAISERROR('" + language.GetNameByCode("WMSAPIInfo102") + @"',16,1);
  839. RETURN
  840. END
  841. SELECT b.DABDOCID AS ID,a.MUSER AS [User],SYSDATETIME() AS MTime,con.Enable AS UpdateTodoQuantity,conStock.Enable AS UpdateStock,a.WorkPoint
  842. FROM ICSWareHouseLotInfoLog a
  843. INNER JOIN ICSDisassemblyDoc b ON a.TransCode=b.DABDOCCode AND a.TransSequence=b.Sequence AND a.WorkPoint=b.WorkPoint
  844. INNER JOIN ICSConfiguration con ON con.Code='Stock003' AND a.WorkPoint=con.WorkPoint
  845. INNER JOIN ICSConfiguration conStock ON conStock.Code='UpdateStock006' AND a.WorkPoint=conStock.WorkPoint
  846. WHERE a.Identification='{0}' AND ERPUpload='0'
  847. GROUP BY b.DABDOCID,a.MUSER,con.Enable,conStock.Enable,a.WorkPoint";
  848. sql = string.Format(sql, Identification);
  849. DataTable dt = DBHelper.SQlReturnData(sql, cmd);
  850. string Inputstr = JsonConvert.SerializeObject(dt);
  851. string resultStr = HTTPHelper.HttpPost(TransType, ERPUrl.DisassemblyDocURL, Inputstr);
  852. Result result = new Result();
  853. result = JsonConvert.DeserializeObject<Result>(resultStr);
  854. if (result.Success)
  855. {
  856. try
  857. {
  858. foreach (DataRow dr in dt.Rows)
  859. {
  860. ICSWareHouseLotInfoService.WareHouseLotInfoLogUpdate(TransType, dr["ID"].ToString(), Identification, "", "", "", "","", cmd, language, BusinessCode);
  861. }
  862. }
  863. catch (Exception ex)
  864. {
  865. log.Debug(ex.ToString());
  866. log.Debug(resultStr);
  867. }
  868. }
  869. else
  870. {
  871. throw new Exception(language.GetNameByCode("WMSAPIInfo080")+result.Message);
  872. }
  873. #endregion
  874. }
  875. catch (Exception)
  876. {
  877. throw;
  878. }
  879. }
  880. #endregion
  881. #region 借用
  882. /// <summary>
  883. /// 借用
  884. /// </summary>
  885. /// <param name="TransCode"></param>
  886. /// <param name="TransSequence"></param>
  887. /// <param name="Quantity"></param>
  888. /// <param name="WorkPoint"></param>
  889. /// <param name="cmd"></param>
  890. public static void BrrowDoc(string TransCode, string TransSequence, string Quantity, string WorkPoint, SqlCommand cmd, Dictionary<string, string> language)
  891. {
  892. try
  893. {
  894. string sql = @"DECLARE @Status VARCHAR(10)
  895. SELECT @Status=a.Status FROM ICSBrrow a
  896. WHERE a.BrrowCode='{0}' AND a.Sequence='{3}' AND a.WorkPoint='{1}'
  897. IF (@Status IS NULL)
  898. BEGIN
  899. RAISERROR('" + language.GetNameByCode("WMSAPIInfo159") + @"',16,1);
  900. RETURN
  901. END
  902. ELSE IF (@Status!='2')
  903. BEGIN
  904. RAISERROR('" + language.GetNameByCode("WMSAPIInfo160") + @"',16,1);
  905. RETURN
  906. END
  907. UPDATE a SET BrrowQuantity=ISNULL(BrrowQuantity,0)+'{2}'
  908. FROM ICSBrrow a
  909. WHERE a.BrrowCode='{0}' AND a.Sequence='{3}' AND a.WorkPoint='{1}'
  910. IF EXISTS(SELECT a.ID FROM ICSBrrow a
  911. WHERE a.BrrowCode='{0}' AND a.Sequence='{3}' and a.WorkPoint='{1}' AND a.Quantity<a.BrrowQuantity)
  912. BEGIN
  913. RAISERROR('" + language.GetNameByCode("WMSAPIInfo091") + @"',16,1);
  914. RETURN
  915. END";
  916. sql = string.Format(sql, TransCode, WorkPoint, Quantity, TransSequence);
  917. if (!DBHelper.ExecuteNonQuery(sql, cmd))
  918. {
  919. throw new Exception(language.GetNameByCode("WMSAPIInfo161"));//"借用单更新失败!");
  920. }
  921. }
  922. catch (Exception)
  923. {
  924. throw;
  925. }
  926. }
  927. /// <summary>
  928. /// 借用接口
  929. /// </summary>
  930. /// <param name="TransType"></param>
  931. /// <param name="Identification"></param>
  932. /// <param name="cmd"></param>
  933. public static void BrrowDocERP(string TransType, string Identification, SqlCommand cmd, Dictionary<string, string> language,string BusinessCode)
  934. {
  935. try
  936. {
  937. #region ERP
  938. string sql = @"SELECT a.FromWarehouseCode+b.BrrowCode+a.MUSER AS Costre,a.FromWarehouseCode AS WarehouseCode,b.BrrowCode,a.MUSER,ROW_NUMBER() OVER (ORDER BY a.FromWarehouseCode,b.BrrowCode,b.BrrowDetailID,a.InvCode) AS Sequence,
  939. a.InvCode,SUM(a.Quantity) AS Quantity,SUM(a.Quantity*(b.Amount/b.Quantity)) AS Amount,b.BrrowDetailID,Enable AS UpdateTodoQuantity
  940. ,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,
  941. 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
  942. INTO #TempERP
  943. FROM ICSWareHouseLotInfoLog a
  944. INNER JOIN ICSInventoryLot lot ON a.LotNo=lot.LotNo AND a.WorkPoint=lot.WorkPoint
  945. INNER JOIN ICSExtension ext ON lot.ExtensionID=ext.ID AND lot.WorkPoint=ext.WorkPoint
  946. INNER JOIN ICSInventory inv ON a.InvCode=inv.InvCode AND a.WorkPoint=inv.WorkPoint
  947. LEFT JOIN ICSInventoryBatchEnable invBat ON a.InvCode=invBat.InvCode AND a.ToWarehouseCode=invBat.WHCode AND a.WorkPoint=invBat.WorkPoint
  948. INNER JOIN ICSBrrow b ON a.TransCode=b.BrrowCode AND a.TransSequence=b.Sequence AND a.WorkPoint=b.WorkPoint
  949. INNER JOIN ICSConfiguration con ON con.Code='Stock002' AND a.WorkPoint=con.WorkPoint
  950. WHERE a.Identification='{0}' AND ERPUpload='0' AND a.BusinessCode = '26'
  951. GROUP BY a.FromWarehouseCode,b.BrrowCode,a.MUSER,a.InvCode,b.BrrowDetailID,Enable
  952. ,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, ''),
  953. 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, '')
  954. SELECT DISTINCT Costre,WorkPoint,'' AS DepCode,WarehouseCode AS WHCode,'' AS SourceType,BrrowCode AS SourceCode,MUSER AS [User],SYSDATETIME() AS MTime,UpdateTodoQuantity FROM #TempERP
  955. SELECT Costre,Sequence,InvCode,Quantity,Amount,BrrowDetailID AS SourceDetailID,ProjectCode,BatchCode,Version,Brand,cFree1,cFree2,cFree3,cFree4,cFree5,cFree6,cFree7,cFree8,cFree9,cFree10 FROM #TempERP
  956. DROP TABLE #TempERP";
  957. sql = string.Format(sql, Identification);
  958. DataSet ds = DBHelper.SQlReturnDataSet(sql, cmd);
  959. string Inputstr = DataToJsonHelper.DataSetToJson(ds, "details", "Costre");
  960. string resultStr = HTTPHelper.HttpPost(TransType, ERPUrl.BrrowDocURL, Inputstr);
  961. Result result = new Result();
  962. result = JsonConvert.DeserializeObject<Result>(resultStr);
  963. if (result.Success)
  964. {
  965. try
  966. {
  967. JArray res = (JArray)JsonConvert.DeserializeObject(result.Data.ToString());
  968. foreach (var item in res)
  969. {
  970. JObject jo = (JObject)item;
  971. JArray resdetail = (JArray)JsonConvert.DeserializeObject(jo["details"].ToString());
  972. foreach (var detail in resdetail)
  973. {
  974. JObject det = (JObject)detail;
  975. 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()
  976. + det["cFree6"].ToString() + det["cFree7"].ToString() + det["cFree8"].ToString() + det["cFree9"].ToString() + det["cFree10"].ToString();
  977. ICSWareHouseLotInfoService.WareHouseLotInfoLogUpdate(TransType, det["SourceDetailID"].ToString(), Identification, jo["ID"].ToString(),
  978. det["DetailID"].ToString(), jo["OtherOutCode"].ToString(), det["Sequence"].ToString(), allcol, cmd, language, BusinessCode);
  979. }
  980. }
  981. }
  982. catch (Exception ex)
  983. {
  984. log.Debug(ex.ToString());
  985. log.Debug(resultStr);
  986. }
  987. }
  988. else
  989. {
  990. throw new Exception(language.GetNameByCode("WMSAPIInfo080") + result.Message);
  991. }
  992. #endregion
  993. }
  994. catch (Exception)
  995. {
  996. throw;
  997. }
  998. }
  999. #endregion
  1000. #region 归还
  1001. /// <summary>
  1002. /// 归还
  1003. /// </summary>
  1004. /// <param name="TransCode"></param>
  1005. /// <param name="TransSequence"></param>
  1006. /// <param name="Quantity"></param>
  1007. /// <param name="WorkPoint"></param>
  1008. /// <param name="cmd"></param>
  1009. public static void ReturnDoc(string LotNo, string Quantity, string WorkPoint, SqlCommand cmd, Dictionary<string, string> language)
  1010. {
  1011. try
  1012. {
  1013. string sql = @"DECLARE @Status VARCHAR(10)
  1014. SELECT @Status=c.Status FROM ICSInventoryLot a
  1015. INNER JOIN ICSInventoryLotDetail b ON a.LotNo=b.LotNo AND a.WorkPoint=b.WorkPoint
  1016. INNER JOIN ICSReturn c ON b.TransCode=c.ReturnCode AND b.TransSequence=c.Sequence AND b.WorkPoint=c.WorkPoint
  1017. WHERE a.LotNo='{0}' AND a.WorkPoint='{1}'
  1018. IF (@Status IS NULL)
  1019. BEGIN
  1020. RAISERROR('" + language.GetNameByCode("WMSAPIInfo081") + @"',16,1);
  1021. RETURN
  1022. END
  1023. ELSE IF (@Status!='2')
  1024. BEGIN
  1025. RAISERROR('" + language.GetNameByCode("WMSAPIInfo142") + @"',16,1);
  1026. RETURN
  1027. END
  1028. UPDATE c SET ReturnQuantity=ISNULL(ReturnQuantity,0)+'{2}'
  1029. FROM ICSInventoryLot a
  1030. INNER JOIN ICSInventoryLotDetail b ON a.LotNo=b.LotNo AND a.WorkPoint=b.WorkPoint
  1031. INNER JOIN ICSReturn c ON b.TransCode=c.ReturnCode AND b.TransSequence=c.Sequence AND b.WorkPoint=c.WorkPoint
  1032. WHERE a.LotNo='{0}' AND a.WorkPoint='{1}'
  1033. IF EXISTS(SELECT a.LotNo FROM ICSInventoryLot a
  1034. INNER JOIN ICSInventoryLotDetail b ON a.LotNo=b.LotNo AND a.WorkPoint=b.WorkPoint
  1035. INNER JOIN ICSReturn c ON b.TransCode=c.ReturnCode AND b.TransSequence=c.Sequence AND b.WorkPoint=c.WorkPoint
  1036. WHERE a.LotNo='{0}' AND a.WorkPoint='{1}' AND c.Quantity<c.ReturnQuantity)
  1037. BEGIN
  1038. RAISERROR('" + language.GetNameByCode("WMSAPIInfo162") + @"',16,1);
  1039. END";
  1040. sql = string.Format(sql, LotNo, WorkPoint, Quantity);
  1041. if (!DBHelper.ExecuteNonQuery(sql, cmd))
  1042. {
  1043. throw new Exception(language.GetNameByCode("WMSAPIInfo163"));//"归还单更新失败!");
  1044. }
  1045. }
  1046. catch (Exception)
  1047. {
  1048. throw;
  1049. }
  1050. }
  1051. /// <summary>
  1052. /// 归还接口
  1053. /// </summary>
  1054. /// <param name="TransType"></param>
  1055. /// <param name="Identification"></param>
  1056. /// <param name="cmd"></param>
  1057. public static void ReturnDocERP(string TransType, string Identification, SqlCommand cmd, Dictionary<string, string> language,string BusinessCode)
  1058. {
  1059. try
  1060. {
  1061. #region ERP
  1062. string sql = @"SELECT a.ToWarehouseCode+b.ReturnCode+a.MUSER AS Costre,a.ToWarehouseCode AS WarehouseCode,b.ReturnCode,a.MUSER,ROW_NUMBER() OVER (ORDER BY a.ToWarehouseCode,b.ReturnCode,b.ReturnDetailID,a.InvCode) AS Sequence,
  1063. a.InvCode,SUM(a.Quantity) AS Quantity,SUM(a.Quantity*(lot.Amount/lot.Quantity)) AS Amount,b.ReturnDetailID,Enable AS UpdateTodoQuantity
  1064. ,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,
  1065. 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
  1066. INTO #TempERP
  1067. FROM ICSWareHouseLotInfoLog a
  1068. INNER JOIN ICSInventoryLot lot ON a.LotNo=lot.LotNo AND a.WorkPoint=lot.WorkPoint
  1069. INNER JOIN ICSExtension ext ON lot.ExtensionID=ext.ID AND lot.WorkPoint=ext.WorkPoint
  1070. INNER JOIN ICSInventory inv ON a.InvCode=inv.InvCode AND a.WorkPoint=inv.WorkPoint
  1071. LEFT JOIN ICSInventoryBatchEnable invBat ON a.InvCode=invBat.InvCode AND a.ToWarehouseCode=invBat.WHCode AND a.WorkPoint=invBat.WorkPoint
  1072. INNER JOIN ICSReturn b ON a.TransCode=b.ReturnCode AND a.TransSequence=b.Sequence AND a.WorkPoint=b.WorkPoint
  1073. INNER JOIN ICSConfiguration con ON con.Code='Stock002' AND a.WorkPoint=con.WorkPoint
  1074. WHERE a.Identification='{0}' AND ERPUpload='0' AND BusinessCode='{1}'
  1075. GROUP BY a.ToWarehouseCode,b.ReturnCode,a.MUSER,a.InvCode,b.ReturnDetailID,Enable
  1076. ,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, ''),
  1077. 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, '')
  1078. SELECT DISTINCT Costre,WorkPoint,'' AS DepCode,WarehouseCode AS WHCode,'' AS SourceType,ReturnCode AS SourceCode,MUSER AS [User],SYSDATETIME() AS MTime,UpdateTodoQuantity FROM #TempERP
  1079. SELECT Costre,Sequence,InvCode,Quantity,Amount,ReturnDetailID AS SourceDetailID,ProjectCode,BatchCode,Version,Brand,cFree1,cFree2,cFree3,cFree4,cFree5,cFree6,cFree7,cFree8,cFree9,cFree10 FROM #TempERP
  1080. DROP TABLE #TempERP";
  1081. sql = string.Format(sql, Identification,BusinessCode);
  1082. DataSet ds = DBHelper.SQlReturnDataSet(sql, cmd);
  1083. string Inputstr = DataToJsonHelper.DataSetToJson(ds, "details", "Costre");
  1084. string resultStr = HTTPHelper.HttpPost(TransType, ERPUrl.ReturnDocURL, Inputstr);
  1085. Result result = new Result();
  1086. result = JsonConvert.DeserializeObject<Result>(resultStr);
  1087. if (result.Success)
  1088. {
  1089. try
  1090. {
  1091. JArray res = (JArray)JsonConvert.DeserializeObject(result.Data.ToString());
  1092. foreach (var item in res)
  1093. {
  1094. JObject jo = (JObject)item;
  1095. JArray resdetail = (JArray)JsonConvert.DeserializeObject(jo["details"].ToString());
  1096. foreach (var detail in resdetail)
  1097. {
  1098. JObject det = (JObject)detail;
  1099. 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()
  1100. + det["cFree6"].ToString() + det["cFree7"].ToString() + det["cFree8"].ToString() + det["cFree9"].ToString() + det["cFree10"].ToString();
  1101. ICSWareHouseLotInfoService.WareHouseLotInfoLogUpdate(TransType, det["SourceDetailID"].ToString(), Identification, jo["ID"].ToString(),
  1102. det["DetailID"].ToString(), jo["OtherInCode"].ToString(), det["Sequence"].ToString(),"", cmd,language, BusinessCode);
  1103. }
  1104. }
  1105. }
  1106. catch (Exception ex)
  1107. {
  1108. log.Debug(ex.ToString());
  1109. log.Debug(resultStr);
  1110. }
  1111. }
  1112. else
  1113. {
  1114. throw new Exception(language.GetNameByCode("WMSAPIInfo080") + result.Message);
  1115. }
  1116. #endregion
  1117. }
  1118. catch (Exception)
  1119. {
  1120. throw;
  1121. }
  1122. }
  1123. #endregion
  1124. #endregion
  1125. }
  1126. }