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

1116 lines
67 KiB

3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
  1. using ICSSoft.Common;
  2. using ICSSoft.Entity;
  3. using Newtonsoft.Json;
  4. using System;
  5. using System.Collections.Generic;
  6. using System.Data;
  7. using System.Data.SqlClient;
  8. using System.Linq;
  9. using System.Net.Http;
  10. using System.Text;
  11. using System.Threading.Tasks;
  12. namespace ICSSoft.DataProject
  13. {
  14. /// <summary>
  15. /// 使用中
  16. /// 更新库存表、日志表
  17. /// </summary>
  18. public class ICSWareHouseLotInfoService
  19. {
  20. private static log4net.ILog log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
  21. /// <summary>
  22. /// 添加库存
  23. /// </summary>
  24. /// <param name="LocationCode"></param>
  25. /// <param name="LotNo"></param>
  26. /// <param name="Quantity"></param>
  27. /// <param name="User"></param>
  28. /// <param name="WorkPoint"></param>
  29. /// <param name="TransType"></param>
  30. /// <param name="BusinessCode"></param>
  31. /// <param name="cmd"></param>
  32. public static void WareHouseLotInfoUp(string Identification, string LocationCode, string LotNo, string Quantity, string User,
  33. string WorkPoint, string TransType, string BusinessCode, SqlCommand cmd, Dictionary<string, string> language,string LogID)
  34. {
  35. try
  36. {
  37. ///添加库存(原条码退回,更新库存;新条码直接入库)
  38. string sql = string.Empty;
  39. if(BusinessCode != TransTypeEnum.SalesReturnBack.GetDescription<DBValue>())
  40. {
  41. sql = @"IF EXISTS(SELECT a.LotNo FROM ICSWareHouseLotInfo a WHERE a.LotNo='{0}' AND a.WorkPoint='{1}')
  42. BEGIN
  43. RAISERROR('" + language.GetNameByCode("WMSAPIInfo164") + @"',16,1);
  44. RETURN
  45. END ";
  46. }
  47. sql += @" IF NOT EXISTS(SELECT F_Account FROM Sys_SRM_User WHERE F_Account='{2}' AND F_Location='{1}')
  48. BEGIN
  49. RAISERROR('" + string.Format(language.GetNameByCode("WMSAPIInfo060"), "{2}") + @"',16,1);
  50. RETURN
  51. END
  52. IF EXISTS(SELECT a.LotNo FROM ICSWareHouseLotInfo a WHERE a.LotNo='{0}' AND a.WorkPoint='{1}')
  53. BEGIN
  54. UPDATE ICSWareHouseLotInfo SET Quantity=ISNULL(Quantity,0)+'{3}' WHERE LotNo='{0}' AND WorkPoint='{1}'
  55. END
  56. ELSE
  57. BEGIN
  58. IF EXISTS(SELECT il.InvCode FROM ICSInventoryLocation il
  59. INNER JOIN ICSInventoryLot a ON a.InvCode=il.InvCode AND a.WorkPoint=il.WorkPoint
  60. WHERE il.Enable='1' AND a.LotNo='{0}' AND a.WorkPoint='{1}')
  61. BEGIN
  62. IF NOT EXISTS(SELECT il.InvCode FROM ICSInventoryLocation il
  63. INNER JOIN ICSInventoryLot a ON a.InvCode=il.InvCode AND a.WorkPoint=il.WorkPoint
  64. WHERE il.Enable='1' AND a.LotNo='{0}' AND a.WorkPoint='{1}' AND il.LocationCode='{4}')
  65. BEGIN
  66. RAISERROR('" + language.GetNameByCode("WMSAPIInfo180") + @"',16,1);
  67. RETURN
  68. END
  69. END
  70. INSERT INTO ICSWareHouseLotInfo(ID,LotNO,WarehouseCode,LocationCode,InvCode,Quantity,InDate,LockQuantity,MUSER,MUSERName,MTIME,WorkPoint,EATTRIBUTE1)
  71. SELECT NEWID(),a.LotNo ,e.WarehouseCode,d.LocationCode,a.InvCode ,'{3}',SYSDATETIME(),'0',f.F_Account ,f.F_RealName ,SYSDATETIME() ,a.WorkPoint ,''
  72. FROM ICSInventoryLot a
  73. INNER JOIN ICSInventoryLotDetail b ON a.LotNo=b.LotNo AND a.WorkPoint=b.WorkPoint
  74. --INNER JOIN ICSOApplyNegDetail c ON b.TransCode=c.OApplyNegCode AND b.TransSequence=c.Sequence AND b.WorkPoint=c.WorkPoint
  75. INNER JOIN ICSLocation d ON d.LocationCode='{4}' AND a.WorkPoint=d.WorkPoint
  76. INNER JOIN ICSWarehouse e ON d.WHID=e.ID AND d.WorkPoint=e.WorkPoint
  77. INNER JOIN Sys_SRM_User f ON f.F_Account='{2}' AND a.WorkPoint=f.F_Location
  78. WHERE a.LotNo='{0}' AND a.WorkPoint='{1}'
  79. END";
  80. sql = string.Format(sql, LotNo, WorkPoint, User, Quantity, LocationCode);
  81. if (!DBHelper.ExecuteNonQuery(sql, cmd))
  82. {
  83. throw new Exception("" + language.GetNameByCode("WMSAPIInfo165") + @"");
  84. }
  85. ///添加日志
  86. sql = @"INSERT INTO ICSWareHouseLotInfoLog(ID,Identification,TransCode,TransSequence,LotNo,InvCode,
  87. FromWarehouseCode,FromLocationCode,ToWarehouseCode,ToLocationCode,Quantity,
  88. Memo,Lock,TransType,BusinessCode,ERPUpload,ERPID,
  89. ERPDetailID,ERPCode,ERPSequence,MUSER,MUSERName,
  90. MTIME,WorkPoint,EATTRIBUTE1,LogID)
  91. SELECT NEWID(),'{3}',b.TransCode,b.TransSequence,a.LotNo ,a.InvCode ,
  92. '','',c.WarehouseCode,c.LocationCode,'{6}',
  93. '','0','{4}','{5}','0','',
  94. '','','',f.F_Account ,f.F_RealName ,
  95. SYSDATETIME() ,a.WorkPoint ,'','{7}'
  96. FROM ICSInventoryLot a
  97. INNER JOIN ICSInventoryLotDetail b ON a.LotNo=b.LotNo AND a.WorkPoint=b.WorkPoint
  98. INNER JOIN ICSWareHouseLotInfo c ON a.LotNo=c.LotNo AND a.WorkPoint=c.WorkPoint
  99. INNER JOIN Sys_SRM_User f ON f.F_Account='{2}' AND a.WorkPoint=f.F_Location
  100. WHERE a.LotNo='{0}' AND a.WorkPoint='{1}'
  101. ";
  102. sql = string.Format(sql, LotNo, WorkPoint, User, Identification, TransType, BusinessCode,Quantity, LogID);
  103. if (!DBHelper.ExecuteNonQuery(sql, cmd))
  104. {
  105. throw new Exception("" + language.GetNameByCode("WMSAPIInfo166") + @"");
  106. }
  107. }
  108. catch (Exception)
  109. {
  110. throw;
  111. }
  112. }
  113. /// <summary>
  114. /// 减少库存
  115. /// </summary>
  116. /// <param name="Identification"></param>
  117. /// <param name="TransCode"></param>
  118. /// <param name="TransSequence"></param>
  119. /// <param name="LotNo"></param>
  120. /// <param name="Quantity"></param>
  121. /// <param name="User"></param>
  122. /// <param name="WorkPoint"></param>
  123. /// <param name="TransType"></param>
  124. /// <param name="BusinessCode"></param>
  125. /// <param name="cmd"></param>
  126. public static void WareHouseLotInfoDown(string Identification, string TransCode, string TransSequence, string LotNo, string Quantity, string User,
  127. string WorkPoint, string TransType, string BusinessCode, SqlCommand cmd, Dictionary<string, string> language,string MergeID="")
  128. {
  129. try
  130. {
  131. ///更新库存
  132. string sql = @"UPDATE ICSWareHouseLotInfo SET Quantity=ISNULL(Quantity,0)-'{2}' WHERE LotNo='{0}' AND WorkPoint='{1}'
  133. IF EXISTS(SELECT a.LotNo FROM ICSWareHouseLotInfo a WHERE a.LotNo='{0}' AND a.WorkPoint='{1}' AND Quantity<0)
  134. BEGIN
  135. RAISERROR('" + language.GetNameByCode("WMSAPIInfo167") + @"',16,1);
  136. RETURN
  137. END";
  138. sql = string.Format(sql, LotNo, WorkPoint, Quantity);
  139. if (!DBHelper.ExecuteNonQuery(sql, cmd))
  140. {
  141. throw new Exception(language.GetNameByCode("WMSAPIInfo168"));//"库存更新失败!");
  142. }
  143. ///添加日志
  144. sql = @"IF NOT EXISTS(SELECT F_Account FROM Sys_SRM_User WHERE F_Account='{2}' AND F_Location='{1}')
  145. BEGIN
  146. RAISERROR('" + string.Format(language.GetNameByCode("WMSAPIInfo060"), "{2}") + @"',16,1);
  147. RETURN
  148. END
  149. INSERT INTO ICSWareHouseLotInfoLog(ID,Identification,TransCode,TransSequence,LotNo,InvCode,
  150. FromWarehouseCode,FromLocationCode,ToWarehouseCode,ToLocationCode,Quantity,
  151. Memo,Lock,TransType,BusinessCode,ERPUpload,ERPID,
  152. ERPDetailID,ERPCode,ERPSequence,MUSER,MUSERName,
  153. MTIME,WorkPoint,EATTRIBUTE1,MergeID)
  154. SELECT NEWID(),'{3}','{4}','{5}',a.LotNo ,a.InvCode ,
  155. c.WarehouseCode,c.LocationCode,'','','{6}',
  156. '','0','{7}','{8}','0','',
  157. '','','',f.F_Account ,f.F_RealName ,
  158. SYSDATETIME() ,a.WorkPoint ,'','{9}'
  159. FROM ICSInventoryLot a
  160. INNER JOIN ICSWareHouseLotInfo c ON a.LotNo=c.LotNo AND a.WorkPoint=c.WorkPoint
  161. INNER JOIN Sys_SRM_User f ON f.F_Account='{2}' AND a.WorkPoint=f.F_Location
  162. WHERE a.LotNo='{0}' AND a.WorkPoint='{1}'
  163. ";
  164. sql = string.Format(sql, LotNo, WorkPoint, User, Identification, TransCode, TransSequence, Quantity, TransType, BusinessCode, MergeID);
  165. if (!DBHelper.ExecuteNonQuery(sql, cmd))
  166. {
  167. throw new Exception("" + language.GetNameByCode("WMSAPIInfo166") + @"");
  168. }
  169. }
  170. catch (Exception)
  171. {
  172. throw;
  173. }
  174. }
  175. /// <summary>
  176. /// 修改库存
  177. /// </summary>
  178. /// <param name="Identification"></param>
  179. /// <param name="TransCode"></param>
  180. /// <param name="TransSequence"></param>
  181. /// <param name="LotNo"></param>
  182. /// <param name="Quantity"></param>
  183. /// <param name="User"></param>
  184. /// <param name="WorkPoint"></param>
  185. /// <param name="TransType"></param>
  186. /// <param name="cmd"></param>
  187. public static void WareHouseLotInfoUpdate(string Identification, string TransCode, string TransSequence, string LotNo, string Quantity, string User,
  188. string WorkPoint, string TransType, SqlCommand cmd, Dictionary<string, string> language)
  189. {
  190. try
  191. {
  192. ///添加日志
  193. string sql = @"IF NOT EXISTS(SELECT F_Account FROM Sys_SRM_User WHERE F_Account='{2}' AND F_Location='{1}')
  194. BEGIN
  195. RAISERROR('" + string.Format(language.GetNameByCode("WMSAPIInfo060"), "{2}") + @"',16,1);
  196. RETURN
  197. END
  198. INSERT INTO ICSWareHouseLotInfoLog(ID,Identification,TransCode,TransSequence,LotNo,InvCode,
  199. FromWarehouseCode,FromLocationCode,ToWarehouseCode,ToLocationCode,Quantity,
  200. Memo,Lock,TransType,BusinessCode,ERPUpload,ERPID,
  201. ERPDetailID,ERPCode,ERPSequence,MUSER,MUSERName,
  202. MTIME,WorkPoint,EATTRIBUTE1)
  203. SELECT NEWID(),'{3}','{4}','{5}',a.LotNo ,a.InvCode ,
  204. a.WarehouseCode,a.LocationCode,'','',a.Quantity,
  205. '','0','{6}','{7}','0','',
  206. '','','',f.F_Account ,f.F_RealName ,
  207. SYSDATETIME() ,a.WorkPoint ,''
  208. FROM ICSWareHouseLotInfo a
  209. INNER JOIN Sys_SRM_User f ON f.F_Account='{2}' AND a.WorkPoint=f.F_Location
  210. WHERE a.LotNo='{0}' AND a.WorkPoint='{1}'
  211. ";
  212. sql = string.Format(sql, LotNo, WorkPoint, User, Identification, TransCode, TransSequence, TransType, TransTypeEnum.LOTCheckBefore.GetDescription<DBValue>());
  213. if (!DBHelper.ExecuteNonQuery(sql, cmd))
  214. {
  215. throw new Exception("" + language.GetNameByCode("WMSAPIInfo166") + @"");
  216. }
  217. ///更新库存
  218. sql = @"UPDATE ICSWareHouseLotInfo SET Quantity='{2}' WHERE LotNo='{0}' AND WorkPoint='{1}'";
  219. sql = string.Format(sql, LotNo, WorkPoint, Quantity);
  220. if (!DBHelper.ExecuteNonQuery(sql, cmd))
  221. {
  222. throw new Exception(language.GetNameByCode("WMSAPIInfo168"));//"库存更新失败!");
  223. }
  224. ///添加日志
  225. sql = @"INSERT INTO ICSWareHouseLotInfoLog(ID,Identification,TransCode,TransSequence,LotNo,InvCode,
  226. FromWarehouseCode,FromLocationCode,ToWarehouseCode,ToLocationCode,Quantity,
  227. Memo,Lock,TransType,BusinessCode,ERPUpload,ERPID,
  228. ERPDetailID,ERPCode,ERPSequence,MUSER,MUSERName,
  229. MTIME,WorkPoint,EATTRIBUTE1)
  230. SELECT NEWID(),'{3}','{4}','{5}',a.LotNo ,a.InvCode ,
  231. a.WarehouseCode,a.LocationCode,'','',a.Quantity,
  232. '','0','{6}','{7}','0','',
  233. '','','',f.F_Account ,f.F_RealName ,
  234. SYSDATETIME() ,a.WorkPoint ,''
  235. FROM ICSWareHouseLotInfo a
  236. INNER JOIN Sys_SRM_User f ON f.F_Account='{2}' AND a.WorkPoint=f.F_Location
  237. WHERE a.LotNo='{0}' AND a.WorkPoint='{1}'
  238. ";
  239. sql = string.Format(sql, LotNo, WorkPoint, User, Identification, TransCode, TransSequence, TransType, TransTypeEnum.LOTCheckAfter.GetDescription<DBValue>());
  240. if (!DBHelper.ExecuteNonQuery(sql, cmd))
  241. {
  242. throw new Exception("" + language.GetNameByCode("WMSAPIInfo166") + @"");
  243. }
  244. }
  245. catch (Exception)
  246. {
  247. throw;
  248. }
  249. }
  250. /// <summary>
  251. /// 调拨
  252. /// </summary>
  253. /// <param name="LocationCode"></param>
  254. /// <param name="LotNo"></param>
  255. /// <param name="Quantity"></param>
  256. /// <param name="User"></param>
  257. /// <param name="WorkPoint"></param>
  258. /// <param name="TransType"></param>
  259. /// <param name="BusinessCode"></param>
  260. /// <param name="cmd"></param>
  261. public static void WareHouseLotInfoTransfer(string Identification, string TransCode, string TransSequence, string WarehouseCode, string LocationCode,
  262. string LotNo, string Quantity, string User, string WorkPoint, string TransType, string BusinessCode, SqlCommand cmd, Dictionary<string, string> language, string MergeID)
  263. {
  264. try
  265. {
  266. ///添加日志
  267. string sql = @"IF NOT EXISTS(SELECT F_Account FROM Sys_SRM_User WHERE F_Account='{2}' AND F_Location='{1}')
  268. BEGIN
  269. RAISERROR('" + string.Format(language.GetNameByCode("WMSAPIInfo060"), "{2}") + @"',16,1);
  270. RETURN
  271. END
  272. INSERT INTO ICSWareHouseLotInfoLog(ID,Identification,TransCode,TransSequence,LotNo,InvCode,
  273. FromWarehouseCode,FromLocationCode,ToWarehouseCode,ToLocationCode,Quantity,
  274. Memo,Lock,TransType,BusinessCode,ERPUpload,ERPID,
  275. ERPDetailID,ERPCode,ERPSequence,MUSER,MUSERName,
  276. MTIME,WorkPoint,EATTRIBUTE1,MergeID)
  277. SELECT NEWID(),'{3}','{4}','{5}',a.LotNo ,a.InvCode ,
  278. c.WarehouseCode,c.LocationCode,'{9}','{10}','{6}',
  279. '','0','{7}','{8}','0','',
  280. '','','',f.F_Account ,f.F_RealName ,
  281. SYSDATETIME() ,a.WorkPoint ,'','{11}'
  282. FROM ICSInventoryLot a
  283. INNER JOIN ICSWareHouseLotInfo c ON a.LotNo=c.LotNo AND a.WorkPoint=c.WorkPoint
  284. INNER JOIN Sys_SRM_User f ON f.F_Account='{2}' AND a.WorkPoint=f.F_Location
  285. WHERE a.LotNo='{0}' AND a.WorkPoint='{1}'
  286. ";
  287. sql = string.Format(sql, LotNo, WorkPoint, User, Identification, TransCode, TransSequence, Quantity, TransType, BusinessCode, WarehouseCode, LocationCode, MergeID);
  288. if (!DBHelper.ExecuteNonQuery(sql, cmd))
  289. {
  290. throw new Exception("" + language.GetNameByCode("WMSAPIInfo166") + @"");
  291. }
  292. ///添加库存
  293. sql = @"IF NOT EXISTS(SELECT a.ID FROM ICSWareHouseLotInfo a WHERE a.LotNo='{0}' AND a.WorkPoint='{1}' AND Quantity>0)
  294. BEGIN
  295. RAISERROR('" + language.GetNameByCode("WMSAPIInfo038") + @"',16,1);
  296. RETURN
  297. END
  298. IF EXISTS(SELECT a.ID FROM ICSWareHouseLotInfo a WHERE LotNo='{0}' AND WorkPoint='{1}' AND a.Quantity<'{4}')
  299. BEGIN
  300. RAISERROR('" + language.GetNameByCode("WMSAPIInfo167") + @"',16,1);
  301. RETURN
  302. END
  303. UPDATE ICSWareHouseLotInfo SET WarehouseCode='{2}',LocationCode='{3}' WHERE LotNo='{0}' AND WorkPoint='{1}'
  304. ";
  305. sql = string.Format(sql, LotNo, WorkPoint, WarehouseCode, LocationCode, Quantity);
  306. if (!DBHelper.ExecuteNonQuery(sql, cmd))
  307. {
  308. throw new Exception(language.GetNameByCode("WMSAPIInfo168"));//"库存表更新失败!");
  309. }
  310. }
  311. catch (Exception)
  312. {
  313. throw;
  314. }
  315. }
  316. /// <summary>
  317. /// 移库
  318. /// </summary>
  319. /// <param name="LocationCode"></param>
  320. /// <param name="LotNo"></param>
  321. /// <param name="Quantity"></param>
  322. /// <param name="User"></param>
  323. /// <param name="WorkPoint"></param>
  324. /// <param name="TransType"></param>
  325. /// <param name="BusinessCode"></param>
  326. /// <param name="cmd"></param>
  327. public static void WareHouseLotInfoLibrary(string Identification, string TransCode, string TransSequence, string WarehouseCode, string LocationCode,
  328. string LotNo, string User, string WorkPoint, string TransType, string BusinessCode, SqlCommand cmd, Dictionary<string, string> language)
  329. {
  330. try
  331. {
  332. ///添加日志
  333. string sql = @"IF NOT EXISTS(SELECT F_Account FROM Sys_SRM_User WHERE F_Account='{2}' AND F_Location='{1}')
  334. BEGIN
  335. RAISERROR('" + string.Format(language.GetNameByCode("WMSAPIInfo060"), "{2}") + @"',16,1);
  336. RETURN
  337. END
  338. INSERT INTO ICSWareHouseLotInfoLog(ID,Identification,TransCode,TransSequence,LotNo,InvCode,
  339. FromWarehouseCode,FromLocationCode,ToWarehouseCode,ToLocationCode,Quantity,
  340. Memo,Lock,TransType,BusinessCode,ERPUpload,ERPID,
  341. ERPDetailID,ERPCode,ERPSequence,MUSER,MUSERName,
  342. MTIME,WorkPoint,EATTRIBUTE1)
  343. SELECT NEWID(),'{3}','{4}','{5}',a.LotNo ,a.InvCode ,
  344. c.WarehouseCode,c.LocationCode,'{8}','{9}',c.Quantity,
  345. '','0','{6}','{7}','0','',
  346. '','','',f.F_Account ,f.F_RealName ,
  347. SYSDATETIME() ,a.WorkPoint ,''
  348. FROM ICSInventoryLot a
  349. INNER JOIN ICSWareHouseLotInfo c ON a.LotNo=c.LotNo AND a.WorkPoint=c.WorkPoint
  350. INNER JOIN Sys_SRM_User f ON f.F_Account='{2}' AND a.WorkPoint=f.F_Location
  351. WHERE a.LotNo='{0}' AND a.WorkPoint='{1}'
  352. ";
  353. sql = string.Format(sql, LotNo, WorkPoint, User, Identification, TransCode, TransSequence, TransType, BusinessCode, WarehouseCode, LocationCode);
  354. if (!DBHelper.ExecuteNonQuery(sql, cmd))
  355. {
  356. throw new Exception("" + language.GetNameByCode("WMSAPIInfo166") + @"");
  357. }
  358. ///添加库存
  359. sql = @"IF NOT EXISTS(SELECT a.ID FROM ICSWareHouseLotInfo a WHERE a.LotNo='{0}' AND a.WorkPoint='{1}' AND Quantity>0)
  360. BEGIN
  361. RAISERROR('" + language.GetNameByCode("WMSAPIInfo038") + @"',16,1);
  362. RETURN
  363. END
  364. UPDATE ICSWareHouseLotInfo SET WarehouseCode='{2}',LocationCode='{3}' WHERE LotNo='{0}' AND WorkPoint='{1}'
  365. ";
  366. sql = string.Format(sql, LotNo, WorkPoint, WarehouseCode, LocationCode);
  367. if (!DBHelper.ExecuteNonQuery(sql, cmd))
  368. {
  369. throw new Exception(language.GetNameByCode("WMSAPIInfo168"));//"库存表更新失败!");
  370. }
  371. }
  372. catch (Exception)
  373. {
  374. throw;
  375. }
  376. }
  377. /// <summary>
  378. /// 两步调入
  379. /// </summary>
  380. /// <param name="LocationCode"></param>
  381. /// <param name="LotNo"></param>
  382. /// <param name="Quantity"></param>
  383. /// <param name="User"></param>
  384. /// <param name="WorkPoint"></param>
  385. /// <param name="TransType"></param>
  386. /// <param name="BusinessCode"></param>
  387. /// <param name="cmd"></param>
  388. public static void WareHouseLotInfoTwoStepTransferDocIn(string Identification, string TransCode, string TransSequence, string WarehouseCode,
  389. string LocationCode, string LotNo, string Quantity, string User, string WorkPoint, string TransType, string BusinessCode, SqlCommand cmd, Dictionary<string, string> language)
  390. {
  391. try
  392. {
  393. ///添加日志
  394. string sql = @"IF NOT EXISTS(SELECT F_Account FROM Sys_SRM_User WHERE F_Account='{2}' AND F_Location='{1}')
  395. BEGIN
  396. RAISERROR('" + string.Format(language.GetNameByCode("WMSAPIInfo060"), "{2}") + @"',16,1);
  397. RETURN
  398. END
  399. INSERT INTO ICSWareHouseLotInfoLog(ID,Identification,TransCode,TransSequence,LotNo,InvCode,
  400. FromWarehouseCode,FromLocationCode,ToWarehouseCode,ToLocationCode,Quantity,
  401. Memo,Lock,TransType,BusinessCode,ERPUpload,ERPID,
  402. ERPDetailID,ERPCode,ERPSequence,MUSER,MUSERName,
  403. MTIME,WorkPoint,EATTRIBUTE1)
  404. SELECT NEWID(),'{3}','{4}','{5}',a.LotNo ,a.InvCode ,
  405. c.WarehouseCode,c.LocationCode,'{9}','{10}','{6}',
  406. '','0','{7}','{8}','0','',
  407. '','','',f.F_Account ,f.F_RealName ,
  408. SYSDATETIME() ,a.WorkPoint ,''
  409. FROM ICSInventoryLot a
  410. INNER JOIN ICSWareHouseLotInfo c ON a.LotNo=c.LotNo AND a.WorkPoint=c.WorkPoint
  411. INNER JOIN Sys_SRM_User f ON f.F_Account='{2}' AND a.WorkPoint=f.F_Location
  412. WHERE a.LotNo='{0}' AND a.WorkPoint='{1}'
  413. ";
  414. sql = string.Format(sql, LotNo, WorkPoint, User, Identification, TransCode, TransSequence, Quantity, TransType, BusinessCode, WarehouseCode, LocationCode);
  415. if (!DBHelper.ExecuteNonQuery(sql, cmd))
  416. {
  417. throw new Exception("" + language.GetNameByCode("WMSAPIInfo166") + @"");
  418. }
  419. ///添加库存
  420. sql = @"IF NOT EXISTS(SELECT a.ID FROM ICSWareHouseLotInfo a WHERE a.LotNo='{0}' AND a.WorkPoint='{1}')
  421. BEGIN
  422. RAISERROR('" + language.GetNameByCode("WMSAPIInfo171") + @"',16,1);
  423. RETURN
  424. END
  425. UPDATE ICSWareHouseLotInfo SET WarehouseCode='{2}',LocationCode='{3}',Quantity='{4}' WHERE LotNo='{0}' AND WorkPoint='{1}'
  426. ";
  427. sql = string.Format(sql, LotNo, WorkPoint, WarehouseCode, LocationCode, Quantity);
  428. if (!DBHelper.ExecuteNonQuery(sql, cmd))
  429. {
  430. throw new Exception(language.GetNameByCode("WMSAPIInfo168"));//"库存表更新失败!");
  431. }
  432. }
  433. catch (Exception)
  434. {
  435. throw;
  436. }
  437. }
  438. /// <summary>
  439. /// 拆分、合并日志
  440. /// </summary>
  441. /// <param name="Identification"></param>
  442. /// <param name="LotNo"></param>
  443. /// <param name="User"></param>
  444. /// <param name="WorkPoint"></param>
  445. /// <param name="TransType"></param>
  446. /// <param name="BusinessCode"></param>
  447. /// <param name="cmd"></param>
  448. public static void WareHouseLotInfoLog(string Identification, string LotNo, string User, string WorkPoint, string TransType, string BusinessCode, SqlCommand cmd, Dictionary<string, string> language)
  449. {
  450. try
  451. {
  452. ///添加日志
  453. string sql = @"IF NOT EXISTS(SELECT F_Account FROM Sys_SRM_User WHERE F_Account='{2}' AND F_Location='{1}')
  454. BEGIN
  455. RAISERROR('" + string.Format(language.GetNameByCode("WMSAPIInfo060"), "{2}") + @"',16,1);
  456. RETURN
  457. END
  458. INSERT INTO ICSWareHouseLotInfoLog(ID,Identification,TransCode,TransSequence,LotNo,InvCode,
  459. FromWarehouseCode,FromLocationCode,ToWarehouseCode,ToLocationCode,Quantity,
  460. Memo,Lock,TransType,BusinessCode,ERPUpload,ERPID,
  461. ERPDetailID,ERPCode,ERPSequence,MUSER,MUSERName,
  462. MTIME,WorkPoint,EATTRIBUTE1)
  463. SELECT NEWID(),'{3}',b.TransCode,b.TransSequence,a.LotNo ,a.InvCode ,
  464. '','',c.WarehouseCode,c.LocationCode,c.Quantity,
  465. '','0','{4}','{5}','0','',
  466. '','','',f.F_Account ,f.F_RealName ,
  467. SYSDATETIME() ,a.WorkPoint ,''
  468. FROM ICSInventoryLot a
  469. INNER JOIN ICSInventoryLotDetail b ON a.LotNo=b.LotNo AND a.WorkPoint=b.WorkPoint
  470. INNER JOIN ICSWareHouseLotInfo c ON a.LotNo=c.LotNo AND a.WorkPoint=c.WorkPoint
  471. INNER JOIN Sys_SRM_User f ON f.F_Account='{2}' AND a.WorkPoint=f.F_Location
  472. WHERE a.LotNo='{0}' AND a.WorkPoint='{1}'
  473. ";
  474. sql = string.Format(sql, LotNo, WorkPoint, User, Identification, TransType, BusinessCode);
  475. if (!DBHelper.ExecuteNonQuery(sql, cmd))
  476. {
  477. throw new Exception("" + language.GetNameByCode("WMSAPIInfo166") + @"");
  478. }
  479. }
  480. catch (Exception)
  481. {
  482. throw;
  483. }
  484. }
  485. /// <summary>
  486. /// 合并
  487. /// </summary>
  488. /// <param name="Identification"></param>
  489. /// <param name="LotNo"></param>
  490. /// <param name="User"></param>
  491. /// <param name="WorkPoint"></param>
  492. /// <param name="TransType"></param>
  493. /// <param name="BusinessCode"></param>
  494. /// <param name="cmd"></param>
  495. public static void WareHouseLotInfoMerge(string Identification, string LotNo, string CurrentLotNo, string Quantity, string User, string WorkPoint, string TransType,
  496. string BusinessCode, SqlCommand cmd, Dictionary<string, string> language)
  497. {
  498. try
  499. {
  500. ///更新目标条码库存
  501. string sql = @"IF NOT EXISTS(SELECT a.LotNo FROM ICSInventoryLot a
  502. INNER JOIN ICSInventoryLot b ON b.LotNo='{3}' AND a.InvCode=b.InvCode AND a.WorkPoint=b.WorkPoint
  503. WHERE a.LotNo='{0}' AND a.WorkPoint='6000')
  504. BEGIN
  505. RAISERROR('" + language.GetNameByCode("WMSAPIInfo170") + @"',16,1);
  506. RETURN
  507. END
  508. IF NOT EXISTS(SELECT a.LotNo FROM ICSWareHouseLotInfo a WHERE a.LotNo='{0}' AND a.WorkPoint='{1}')
  509. BEGIN
  510. RAISERROR('" + language.GetNameByCode("WMSAPIInfo171") + @"',16,1);
  511. RETURN
  512. END
  513. UPDATE ICSWareHouseLotInfo SET Quantity=ISNULL(Quantity,0)+'{2}' WHERE LotNo='{0}' AND WorkPoint='{1}'
  514. ";
  515. sql = string.Format(sql, LotNo, WorkPoint, Quantity,CurrentLotNo);
  516. if (!DBHelper.ExecuteNonQuery(sql, cmd))
  517. {
  518. throw new Exception(language.GetNameByCode("WMSAPIInfo169"));//"目标条码库存更新失败!");
  519. }
  520. ///更新原条码库存
  521. sql = @"UPDATE ICSWareHouseLotInfo SET Quantity=ISNULL(Quantity,0)-'{2}' WHERE LotNo='{0}' AND WorkPoint='{1}'
  522. IF EXISTS(SELECT a.LotNo FROM ICSWareHouseLotInfo a WHERE a.LotNo='{0}' AND a.WorkPoint='{1}' AND Quantity<0)
  523. BEGIN
  524. RAISERROR('" + language.GetNameByCode("WMSAPIInfo167") + @"',16,1);
  525. RETURN
  526. END";
  527. sql = string.Format(sql, CurrentLotNo, WorkPoint, Quantity);
  528. if (!DBHelper.ExecuteNonQuery(sql, cmd))
  529. {
  530. throw new Exception(language.GetNameByCode("WMSAPIInfo168"));//"库存更新失败!");
  531. }
  532. ///添加日志
  533. sql = @"IF NOT EXISTS(SELECT F_Account FROM Sys_SRM_User WHERE F_Account='{2}' AND F_Location='{1}')
  534. BEGIN
  535. RAISERROR('" + string.Format(language.GetNameByCode("WMSAPIInfo060"), "{2}") + @"',16,1);
  536. RETURN
  537. END
  538. INSERT INTO ICSWareHouseLotInfoLog(ID,Identification,TransCode,TransSequence,LotNo,InvCode,
  539. FromWarehouseCode,FromLocationCode,ToWarehouseCode,ToLocationCode,Quantity,
  540. Memo,Lock,TransType,BusinessCode,ERPUpload,ERPID,
  541. ERPDetailID,ERPCode,ERPSequence,MUSER,MUSERName,
  542. MTIME,WorkPoint,EATTRIBUTE1)
  543. SELECT NEWID(),'{3}',b.TransCode,b.TransSequence,a.LotNo ,a.InvCode ,
  544. '','',c.WarehouseCode,c.LocationCode,c.Quantity,
  545. '','0','{4}','{5}','0','',
  546. '','','',f.F_Account ,f.F_RealName ,
  547. SYSDATETIME() ,a.WorkPoint ,''
  548. FROM ICSInventoryLot a
  549. INNER JOIN ICSInventoryLotDetail b ON a.LotNo=b.LotNo AND a.WorkPoint=b.WorkPoint
  550. INNER JOIN ICSWareHouseLotInfo c ON a.LotNo=c.LotNo AND a.WorkPoint=c.WorkPoint
  551. INNER JOIN Sys_SRM_User f ON f.F_Account='{2}' AND a.WorkPoint=f.F_Location
  552. WHERE a.LotNo='{0}' AND a.WorkPoint='{1}'
  553. ";
  554. sql = string.Format(sql, CurrentLotNo, WorkPoint, User, Identification, TransType, BusinessCode);
  555. if (!DBHelper.ExecuteNonQuery(sql, cmd))
  556. {
  557. throw new Exception("" + language.GetNameByCode("WMSAPIInfo166") + @"");
  558. }
  559. }
  560. catch (Exception)
  561. {
  562. throw;
  563. }
  564. }
  565. /// <summary>
  566. /// 拆分
  567. /// </summary>
  568. /// <param name="Identification"></param>
  569. /// <param name="LotNo"></param>
  570. /// <param name="User"></param>
  571. /// <param name="WorkPoint"></param>
  572. /// <param name="TransType"></param>
  573. /// <param name="BusinessCode"></param>
  574. /// <param name="cmd"></param>
  575. public static void WareHouseLotInfoSplit(string Identification, string LotNo, string CurrentLotNo, string Quantity, string User, string WorkPoint, string TransType,
  576. string BusinessCode, SqlCommand cmd, Dictionary<string, string> language)
  577. {
  578. try
  579. {
  580. ///更新库存
  581. string sql = @"UPDATE ICSWareHouseLotInfo SET Quantity=ISNULL(Quantity,0)-'{2}' WHERE LotNo='{0}' AND WorkPoint='{1}'
  582. IF EXISTS(SELECT a.LotNo FROM ICSWareHouseLotInfo a WHERE a.LotNo='{0}' AND a.WorkPoint='{1}' AND Quantity<0)
  583. BEGIN
  584. RAISERROR('" + language.GetNameByCode("WMSAPIInfo167") + @"',16,1);
  585. RETURN
  586. END";
  587. sql = string.Format(sql, LotNo, WorkPoint, Quantity);
  588. if (!DBHelper.ExecuteNonQuery(sql, cmd))
  589. {
  590. throw new Exception(language.GetNameByCode("WMSAPIInfo168"));//"库存更新失败!");
  591. }
  592. #region 添加库存
  593. //插入条码表
  594. sql = @"IF NOT EXISTS(SELECT F_Account FROM Sys_SRM_User WHERE F_Account='{2}' AND F_Location='{1}')
  595. BEGIN
  596. RAISERROR('" + string.Format(language.GetNameByCode("WMSAPIInfo060"), "{2}") + @"',16,1);
  597. RETURN
  598. END
  599. IF EXISTS(SELECT a.LotNo FROM ICSInventoryLot a WHERE a.LotNo='{4}' AND a.WorkPoint='{1}')
  600. BEGIN
  601. RAISERROR('" + language.GetNameByCode("WMSAPIInfo172") + @"',16,1);
  602. RETURN
  603. END
  604. INSERT INTO ICSInventoryLot(ID,LotNo,InvCode,ProductDate,ExpirationDate,Quantity,ExtensionID,Type,MUSER,MUSERName,MTIME,WorkPoint,EATTRIBUTE1)
  605. SELECT NEWID(),'{4}' ,a.InvCode,a.ProductDate,a.ExpirationDate ,'{3}',a.ExtensionID,'10',f.F_Account ,f.F_RealName ,SYSDATETIME() ,a.WorkPoint ,a.LotNo
  606. FROM ICSInventoryLot a
  607. INNER JOIN Sys_SRM_User f ON f.F_Account='{2}' AND a.WorkPoint=f.F_Location
  608. WHERE a.LotNo='{0}' AND a.WorkPoint='{1}'";
  609. sql = string.Format(sql, LotNo, WorkPoint, User, Quantity, CurrentLotNo);
  610. if (!DBHelper.ExecuteNonQuery(sql, cmd))
  611. {
  612. throw new Exception(language.GetNameByCode("WMSAPIInfo173"));//"条码表写入失败!");
  613. }
  614. //插入条码单据表
  615. sql = @"INSERT INTO ICSInventoryLotDetail(LotNo,TransCode,TransSequence,MUSER,MUSERName,MTIME,WorkPoint)
  616. SELECT '{3}',b.TransCode,b.TransSequence,f.F_Account ,f.F_RealName ,SYSDATETIME() ,a.WorkPoint
  617. FROM ICSInventoryLot a
  618. INNER JOIN ICSInventoryLotDetail b ON a.LotNo=b.LotNo AND a.WorkPoint=b.WorkPoint
  619. INNER JOIN Sys_SRM_User f ON f.F_Account='{2}' AND a.WorkPoint=f.F_Location
  620. WHERE a.LotNo='{0}' AND a.WorkPoint='{1}'";
  621. sql = string.Format(sql, LotNo, WorkPoint, User, CurrentLotNo);
  622. if (!DBHelper.ExecuteNonQuery(sql, cmd))
  623. {
  624. throw new Exception(language.GetNameByCode("WMSAPIInfo174"));//"条码单据表写入失败!");
  625. }
  626. ///添加库存
  627. sql = @"IF EXISTS(SELECT a.LotNo FROM ICSWareHouseLotInfo a WHERE a.LotNo='{0}' AND a.WorkPoint='{1}')
  628. BEGIN
  629. RAISERROR('" + language.GetNameByCode("WMSAPIInfo164") + @"',16,1);
  630. RETURN
  631. END
  632. IF EXISTS(SELECT il.InvCode FROM ICSInventoryLocation il
  633. INNER JOIN ICSInventoryLot a ON a.InvCode=il.InvCode AND a.WorkPoint=il.WorkPoint
  634. INNER JOIN ICSWareHouseLotInfo d ON a.EATTRIBUTE1=d.LotNo AND a.WorkPoint=d.WorkPoint
  635. WHERE il.Enable='1' AND a.LotNo='{0}' AND a.WorkPoint='{1}')
  636. BEGIN
  637. IF NOT EXISTS(SELECT il.InvCode FROM ICSInventoryLocation il
  638. INNER JOIN ICSInventoryLot a ON a.InvCode=il.InvCode AND a.WorkPoint=il.WorkPoint
  639. INNER JOIN ICSWareHouseLotInfo d ON a.EATTRIBUTE1=d.LotNo AND a.WorkPoint=d.WorkPoint AND il.LocationCode=d.LocationCode
  640. WHERE il.Enable='1' AND a.LotNo='{0}' AND a.WorkPoint='{1}')
  641. BEGIN
  642. RAISERROR('" + language.GetNameByCode("WMSAPIInfo180") + @"',16,1);
  643. RETURN
  644. END
  645. END
  646. INSERT INTO ICSWareHouseLotInfo(ID,LotNO,WarehouseCode,LocationCode,InvCode,Quantity,InDate,LockQuantity,MUSER,MUSERName,MTIME,WorkPoint,EATTRIBUTE1)
  647. SELECT NEWID(),a.LotNo ,d.WarehouseCode,d.LocationCode,a.InvCode ,'{3}',SYSDATETIME(),'0',f.F_Account ,f.F_RealName ,SYSDATETIME() ,a.WorkPoint ,''
  648. FROM ICSInventoryLot a
  649. INNER JOIN ICSInventoryLotDetail b ON a.LotNo=b.LotNo AND a.WorkPoint=b.WorkPoint
  650. INNER JOIN ICSWareHouseLotInfo d ON a.EATTRIBUTE1=d.LotNo AND a.WorkPoint=d.WorkPoint
  651. INNER JOIN Sys_SRM_User f ON f.F_Account='{2}' AND a.WorkPoint=f.F_Location
  652. WHERE a.LotNo='{0}' AND a.WorkPoint='{1}'";
  653. sql = string.Format(sql, CurrentLotNo, WorkPoint, User, Quantity);
  654. if (!DBHelper.ExecuteNonQuery(sql, cmd))
  655. {
  656. throw new Exception("" + language.GetNameByCode("WMSAPIInfo165") + @"");
  657. }
  658. ///添加日志
  659. sql = @"INSERT INTO ICSWareHouseLotInfoLog(ID,Identification,TransCode,TransSequence,LotNo,InvCode,
  660. FromWarehouseCode,FromLocationCode,ToWarehouseCode,ToLocationCode,Quantity,
  661. Memo,Lock,TransType,BusinessCode,ERPUpload,ERPID,
  662. ERPDetailID,ERPCode,ERPSequence,MUSER,MUSERName,
  663. MTIME,WorkPoint,EATTRIBUTE1)
  664. SELECT NEWID(),'{3}',b.TransCode,b.TransSequence,a.LotNo ,a.InvCode ,
  665. '','',c.WarehouseCode,c.LocationCode,c.Quantity,
  666. '','0','{4}','{5}','0','',
  667. '','','',f.F_Account ,f.F_RealName ,
  668. SYSDATETIME() ,a.WorkPoint ,''
  669. FROM ICSInventoryLot a
  670. INNER JOIN ICSInventoryLotDetail b ON a.LotNo=b.LotNo AND a.WorkPoint=b.WorkPoint
  671. INNER JOIN ICSWareHouseLotInfo c ON a.LotNo=c.LotNo AND a.WorkPoint=c.WorkPoint
  672. INNER JOIN Sys_SRM_User f ON f.F_Account='{2}' AND a.WorkPoint=f.F_Location
  673. WHERE a.LotNo='{0}' AND a.WorkPoint='{1}'
  674. ";
  675. sql = string.Format(sql, CurrentLotNo, WorkPoint, User, Identification, TransType, BusinessCode);
  676. if (!DBHelper.ExecuteNonQuery(sql, cmd))
  677. {
  678. throw new Exception("" + language.GetNameByCode("WMSAPIInfo166") + @"");
  679. }
  680. #endregion
  681. }
  682. catch (Exception)
  683. {
  684. throw;
  685. }
  686. }
  687. /// <summary>
  688. /// 回写ERP ID
  689. /// </summary>
  690. /// <param name="TransType"></param>
  691. /// <param name="SourceDetailID"></param>
  692. /// <param name="Identification"></param>
  693. /// <param name="ID"></param>
  694. /// <param name="DetailID"></param>
  695. /// <param name="Code"></param>
  696. /// <param name="Sequence"></param>
  697. /// <param name="cmd"></param>
  698. public static void WareHouseLotInfoLogUpdate(string TransType, string SourceDetailID, string Identification, string ID, string DetailID, string Code, string Sequence, SqlCommand cmd, Dictionary<string, string> language)
  699. {
  700. string ERPupdate = string.Empty;
  701. try
  702. {
  703. //采购入库
  704. if (TransType == TransTypeEnum.PurchaseReceiveDoc.GetDescription())
  705. {
  706. ERPupdate = @"UPDATE a set ERPID='{2}',ERPDetailID='{3}',ERPCode='{4}',ERPSequence='{5}',ERPUpload='1'
  707. FROM ICSWareHouseLotInfoLog a
  708. INNER JOIN ICSInventoryLotDetail b ON a.LotNo=b.LotNo AND a.WorkPoint=b.WorkPoint
  709. INNER JOIN ICSPurchaseOrder c ON b.TransCode=c.POCode AND b.TransSequence=c.Sequence AND a.WorkPoint=c.WorkPoint
  710. WHERE c.PODetailID='{0}' AND a.Identification='{1}' AND ERPUpload='0'
  711. ";
  712. }
  713. //审核的到货单
  714. else if (TransType == TransTypeEnum.DeliveryNotice.GetDescription())
  715. {
  716. ERPupdate = @"UPDATE a set ERPID='{2}',ERPDetailID='{3}',ERPCode='{4}',ERPSequence='{5}',ERPUpload='1'
  717. FROM ICSWareHouseLotInfoLog a
  718. INNER JOIN ICSInventoryLotDetail b ON a.LotNo=b.LotNo AND a.WorkPoint=b.WorkPoint
  719. INNER JOIN ICSDeliveryNotice c ON b.TransCode=c.DNCode AND b.TransSequence=c.Sequence AND a.WorkPoint=c.WorkPoint
  720. WHERE c.DNDetailID='{0}' AND a.Identification='{1}' AND ERPUpload='0'
  721. ";
  722. }
  723. //采购拒收
  724. else if (TransType == TransTypeEnum.PurchaseRejectDoc.GetDescription())
  725. {
  726. ERPupdate = @"UPDATE a set ERPID='{2}',ERPDetailID='{3}',ERPCode='{4}',ERPSequence='{5}',ERPUpload='1'
  727. FROM ICSWareHouseLotInfoLog a
  728. INNER JOIN ICSInventoryLotDetail b ON a.LotNo=b.LotNo AND a.WorkPoint=b.WorkPoint
  729. INNER JOIN ICSDeliveryNotice c ON b.TransCode=c.DNCode AND b.TransSequence=c.Sequence AND a.WorkPoint=c.WorkPoint
  730. WHERE c.DNDetailID='{0}' AND a.Identification='{1}' AND ERPUpload='0'
  731. ";
  732. }
  733. //审核的委外到货单
  734. else if (TransType == TransTypeEnum.ODeliveryNotice.GetDescription())
  735. {
  736. ERPupdate = @"UPDATE a set ERPID='{2}',ERPDetailID='{3}',ERPCode='{4}',ERPSequence='{5}',ERPUpload='1'
  737. FROM ICSWareHouseLotInfoLog a
  738. INNER JOIN ICSInventoryLotDetail b ON a.LotNo=b.LotNo AND a.WorkPoint=b.WorkPoint
  739. INNER JOIN ICSODeliveryNotice c ON b.TransCode=c.ODNCode AND b.TransSequence=c.Sequence AND a.WorkPoint=c.WorkPoint
  740. WHERE c.ODNDetailID='{0}' AND a.Identification='{1}' AND ERPUpload='0'
  741. ";
  742. }
  743. //委外拒收
  744. else if (TransType == TransTypeEnum.OutsourcingRejectDoc.GetDescription())
  745. {
  746. ERPupdate = @"UPDATE a set ERPID='{2}',ERPDetailID='{3}',ERPCode='{4}',ERPSequence='{5}',ERPUpload='1'
  747. FROM ICSWareHouseLotInfoLog a
  748. INNER JOIN ICSInventoryLotDetail b ON a.LotNo=b.LotNo AND a.WorkPoint=b.WorkPoint
  749. INNER JOIN ICSODeliveryNotice c ON b.TransCode=c.ODNCode AND b.TransSequence=c.Sequence AND a.WorkPoint=c.WorkPoint
  750. WHERE c.ODNDetailID='{0}' AND a.Identification='{1}' AND ERPUpload='0'
  751. ";
  752. }
  753. //采购退货
  754. else if (TransType == TransTypeEnum.PurchaseReceiveDoctNegative.GetDescription())
  755. {
  756. ERPupdate = @"UPDATE a set ERPID='{2}',ERPDetailID='{3}',ERPCode='{4}',ERPSequence='{5}',ERPUpload='1'
  757. FROM ICSWareHouseLotInfoLog a
  758. INNER JOIN ICSDeliveryNotice c ON a.TransCode=c.DNCode AND a.TransSequence=c.Sequence AND a.WorkPoint=c.WorkPoint
  759. WHERE c.DNDetailID='{0}' AND a.Identification='{1}' AND ERPUpload='0' AND c.DNType='2'
  760. ";
  761. }
  762. //委外发料
  763. else if (TransType == TransTypeEnum.OutsourcingIssueDoc.GetDescription())
  764. {
  765. ERPupdate = @"UPDATE a set ERPID='{2}',ERPDetailID='{3}',ERPCode='{4}',ERPSequence='{5}',ERPUpload='1'
  766. FROM ICSWareHouseLotInfoLog a
  767. INNER JOIN ICSOutsourcingOrder y ON a.TransCode=y.OOCode AND a.WorkPoint=y.WorkPoint
  768. INNER JOIN ICSOOPick x ON x.OODetailID=y.OODetailID AND a.TransSequence=y.Sequence+'-'+x.Sequence AND x.WorkPoint=y.WorkPoint
  769. WHERE x.PickID='{0}' AND a.Identification='{1}' AND ERPUpload='0'
  770. ";
  771. }
  772. //委外退料
  773. else if (TransType == TransTypeEnum.ICSOutsourcingIssueDoNegative.GetDescription()
  774. || TransType == TransTypeEnum.ICSOutsourcingIssueDoNegativeApply.GetDescription()
  775. || TransType == TransTypeEnum.ICSOutsourcingIssueDoNegativeIssue.GetDescription())
  776. {
  777. ERPupdate = @"UPDATE a set ERPID='{2}',ERPDetailID='{3}',ERPCode='{4}',ERPSequence='{5}',ERPUpload='1'
  778. FROM ICSWareHouseLotInfoLog a
  779. INNER JOIN ICSInventoryLotDetail b ON a.LotNo=b.LotNo AND a.WorkPoint=b.WorkPoint
  780. INNER JOIN ICSOApplyNegDetail c ON b.TransCode=c.OApplyNegCode AND b.TransSequence=c.Sequence AND b.WorkPoint=c.WorkPoint
  781. WHERE c.SourceDetailID='{0}' AND a.Identification='{1}' AND ERPUpload='0'
  782. UPDATE a set ERPID='{2}',ERPDetailID='{3}',ERPCode='{4}',ERPSequence='{5}',ERPUpload='1'
  783. FROM ICSWareHouseLotInfoLog a
  784. INNER JOIN ICSWareHouseLotInfoLog b ON a.EATTRIBUTE1=b.ID AND a.WorkPoint=b.WorkPoint
  785. INNER JOIN ICSOutsourcingOrder y ON b.TransCode=y.OOCode AND b.WorkPoint=y.WorkPoint
  786. INNER JOIN ICSOOPick x ON x.OODetailID=y.OODetailID AND x.WorkPoint=y.WorkPoint AND b.TransSequence = y.Sequence + '-' + x.Sequence
  787. WHERE x.PickID='{0}' AND a.Identification='{1}' AND a.ERPUpload='0'
  788. UPDATE a set ERPID='{2}',ERPDetailID='{3}',ERPCode='{4}',ERPSequence='{5}',ERPUpload='1'
  789. FROM ICSWareHouseLotInfoLog a
  790. INNER JOIN ICSWareHouseLotInfoLog b ON a.EATTRIBUTE1=b.ID AND a.WorkPoint=b.WorkPoint
  791. INNER JOIN ICSOApply z ON b.TransCode=z.ApplyCode AND b.TransSequence=z.Sequence AND b.WorkPoint=z.WorkPoint
  792. WHERE z.ApplyDetailID='{0}' AND a.Identification='{1}' AND a.ERPUpload='0'
  793. UPDATE a set ERPID='{2}',ERPDetailID='{3}',ERPCode='{4}',ERPSequence='{5}',ERPUpload='1'
  794. FROM ICSWareHouseLotInfoLog a
  795. INNER JOIN ICSWareHouseLotInfoLog b ON a.EATTRIBUTE1=b.ID AND a.WorkPoint=b.WorkPoint
  796. INNER JOIN ICSOIssue m ON b.TransCode=m.IssueCode AND b.TransSequence=m.Sequence AND b.WorkPoint=m.WorkPoint
  797. LEFT JOIN ICSOOPick x ON m.PickID=x.PickID AND m.WorkPoint=x.WorkPoint
  798. LEFT JOIN ICSOutsourcingOrder y ON x.OODetailID=y.OODetailID AND x.WorkPoint=y.WorkPoint
  799. LEFT JOIN ICSOApply z ON m.ApplyDetailID=z.ApplyDetailID AND m.WorkPoint=z.WorkPoint
  800. WHERE ISNULL(m.PickID, m.ApplyDetailID)='{0}' AND a.Identification='{1}' AND a.ERPUpload='0'
  801. ";
  802. }
  803. //委外入库
  804. else if (TransType == TransTypeEnum.OutsourcingReceiveDoc.GetDescription())
  805. {
  806. ERPupdate = @"UPDATE a set ERPID='{2}',ERPDetailID='{3}',ERPCode='{4}',ERPSequence='{5}',ERPUpload='1'
  807. FROM ICSWareHouseLotInfoLog a
  808. INNER JOIN ICSInventoryLotDetail b ON a.LotNo=b.LotNo AND a.WorkPoint=b.WorkPoint
  809. INNER JOIN ICSOutsourcingOrder c ON b.TransCode=c.OOCode AND b.TransSequence=c.Sequence AND a.WorkPoint=c.WorkPoint
  810. WHERE c.OODetailID='{0}' AND a.Identification='{1}' AND ERPUpload='0'
  811. ";
  812. }
  813. //委外退货
  814. else if (TransType == TransTypeEnum.OutsourcingReturnBack.GetDescription())
  815. {
  816. ERPupdate = @"UPDATE a set ERPID='{2}',ERPDetailID='{3}',ERPCode='{4}',ERPSequence='{5}',ERPUpload='1'
  817. FROM ICSWareHouseLotInfoLog a
  818. INNER JOIN ICSODeliveryNotice c ON a.TransCode=c.ODNCode AND a.TransSequence=c.Sequence AND a.WorkPoint=c.WorkPoint
  819. WHERE c.ODNDetailID='{0}' AND a.Identification='{1}' AND ERPUpload='0' AND c.ODNType='2'
  820. ";
  821. }
  822. //生产发料
  823. else if (TransType == TransTypeEnum.MOIssueDoc.GetDescription())
  824. {
  825. ERPupdate = @"UPDATE a set ERPID='{2}',ERPDetailID='{3}',ERPCode='{4}',ERPSequence='{5}',ERPUpload='1'
  826. FROM ICSWareHouseLotInfoLog a
  827. INNER JOIN ICSMO y ON a.TransCode=y.MOCode AND a.WorkPoint=y.WorkPoint
  828. INNER JOIN ICSMOPick x ON x.MODetailID=y.MODetailID AND a.TransSequence=y.Sequence+'-'+x.Sequence AND x.WorkPoint=y.WorkPoint
  829. WHERE x.PickID='{0}' AND a.Identification='{1}' AND ERPUpload='0'
  830. ";
  831. }
  832. //生产退料
  833. else if (TransType == TransTypeEnum.MOIssueDocNegative.GetDescription()
  834. || TransType == TransTypeEnum.MOIssueDocNegativeApply.GetDescription()
  835. || TransType == TransTypeEnum.MOIssueDocNegativeIssue.GetDescription())
  836. {
  837. ERPupdate = @"UPDATE a set ERPID='{2}',ERPDetailID='{3}',ERPCode='{4}',ERPSequence='{5}',ERPUpload='1'
  838. FROM ICSWareHouseLotInfoLog a
  839. INNER JOIN ICSInventoryLotDetail b ON a.LotNo=b.LotNo AND a.WorkPoint=b.WorkPoint
  840. INNER JOIN ICSMOApplyNegDetail c ON b.TransCode=c.ApplyNegCode AND b.TransSequence=c.Sequence AND b.WorkPoint=c.WorkPoint
  841. WHERE c.SourceDetailID='{0}' AND a.Identification='{1}' AND ERPUpload='0'
  842. UPDATE a set ERPID='{2}',ERPDetailID='{3}',ERPCode='{4}',ERPSequence='{5}',ERPUpload='1'
  843. FROM ICSWareHouseLotInfoLog a
  844. INNER JOIN ICSWareHouseLotInfoLog b ON a.EATTRIBUTE1=b.ID AND a.WorkPoint=b.WorkPoint
  845. INNER JOIN ICSMO y ON b.TransCode=y.MOCode AND b.WorkPoint=y.WorkPoint
  846. INNER JOIN ICSMOPick x ON x.MODetailID=y.MODetailID AND x.WorkPoint=y.WorkPoint AND b.TransSequence = y.Sequence + '-' + x.Sequence
  847. WHERE x.PickID='{0}' AND a.Identification='{1}' AND a.ERPUpload='0'
  848. UPDATE a set ERPID='{2}',ERPDetailID='{3}',ERPCode='{4}',ERPSequence='{5}',ERPUpload='1'
  849. FROM ICSWareHouseLotInfoLog a
  850. INNER JOIN ICSWareHouseLotInfoLog b ON a.EATTRIBUTE1=b.ID AND a.WorkPoint=b.WorkPoint
  851. INNER JOIN ICSMOApply z ON b.TransCode=z.ApplyCode AND b.TransSequence=z.Sequence AND b.WorkPoint=z.WorkPoint
  852. WHERE z.ApplyDetailID='{0}' AND a.Identification='{1}' AND a.ERPUpload='0'
  853. UPDATE a set ERPID='{2}',ERPDetailID='{3}',ERPCode='{4}',ERPSequence='{5}',ERPUpload='1'
  854. FROM ICSWareHouseLotInfoLog a
  855. INNER JOIN ICSWareHouseLotInfoLog b ON a.EATTRIBUTE1=b.ID AND a.WorkPoint=b.WorkPoint
  856. INNER JOIN ICSMOIssue m ON b.TransCode=m.IssueCode AND b.TransSequence=m.Sequence AND b.WorkPoint=m.WorkPoint
  857. LEFT JOIN ICSMOPick x ON m.PickID=x.PickID AND m.WorkPoint=x.WorkPoint
  858. LEFT JOIN ICSMO y ON x.MODetailID=y.MODetailID AND x.WorkPoint=y.WorkPoint
  859. LEFT JOIN ICSMOApply z ON m.ApplyDetailID=z.ApplyDetailID AND m.WorkPoint=z.WorkPoint
  860. WHERE ISNULL(m.PickID, m.ApplyDetailID)='{0}' AND a.Identification='{1}' AND a.ERPUpload='0'
  861. ";
  862. }
  863. //生产入库
  864. else if (TransType == TransTypeEnum.ManufactureReceiveDoc.GetDescription())
  865. {
  866. ERPupdate = @"UPDATE a set ERPID='{2}',ERPDetailID='{3}',ERPCode='{4}',ERPSequence='{5}',ERPUpload='1'
  867. FROM ICSWareHouseLotInfoLog a
  868. INNER JOIN ICSInventoryLotDetail b ON a.LotNo=b.LotNo AND a.WorkPoint=b.WorkPoint
  869. INNER JOIN ICSMO c ON b.TransCode=c.MOCode AND b.TransSequence=c.Sequence AND a.WorkPoint=c.WorkPoint
  870. WHERE c.MODetailID='{0}' AND a.Identification='{1}' AND ERPUpload='0'
  871. ";
  872. }
  873. //开立的生产入库单
  874. else if (TransType == TransTypeEnum.ManufactureReceive.GetDescription())
  875. {
  876. ERPupdate = @"UPDATE a set ERPID='{2}',ERPDetailID='{3}',ERPCode='{4}',ERPSequence='{5}',ERPUpload='1'
  877. FROM ICSWareHouseLotInfoLog a
  878. INNER JOIN ICSInventoryLotDetail b ON a.LotNo=b.LotNo AND a.WorkPoint=b.WorkPoint
  879. INNER JOIN ICSManufactureReceive c ON b.TransCode=c.RCVCode AND b.TransSequence=c.Sequence AND a.WorkPoint=c.WorkPoint
  880. WHERE c.RCVID='{0}' AND a.Identification='{1}' AND ERPUpload='0' AND c.Type='1'
  881. ";
  882. }
  883. //销售出库
  884. else if (TransType == TransTypeEnum.SalesShipmentDoc.GetDescription())
  885. {
  886. ERPupdate = @"UPDATE a set ERPID='{2}',ERPDetailID='{3}',ERPCode='{4}',ERPSequence='{5}',ERPUpload='1'
  887. FROM ICSWareHouseLotInfoLog a
  888. INNER JOIN ICSSDN c ON a.TransCode=c.SDNCode AND a.TransSequence=c.Sequence AND a.WorkPoint=c.WorkPoint
  889. WHERE c.SDNDetailID='{0}' AND a.Identification='{1}' AND ERPUpload='0' AND c.Type='1'
  890. ";
  891. }
  892. //销售退货
  893. else if (TransType == TransTypeEnum.SalesShipmentDocNegative.GetDescription())
  894. {
  895. ERPupdate = @"UPDATE a set ERPID='{2}',ERPDetailID='{3}',ERPCode='{4}',ERPSequence='{5}',ERPUpload='1'
  896. FROM ICSWareHouseLotInfoLog a
  897. INNER JOIN ICSSDN c ON a.TransCode=c.SDNCode AND a.TransSequence=c.Sequence AND a.WorkPoint=c.WorkPoint
  898. WHERE c.SDNDetailID='{0}' AND a.Identification='{1}' AND ERPUpload='0' AND c.Type='2'
  899. ";
  900. }
  901. //一步调拨
  902. else if (TransType == TransTypeEnum.OneStepTransferDocIn.GetDescription())
  903. {
  904. ERPupdate = @"UPDATE a set ERPID='{2}',ERPDetailID='{3}',ERPCode='{4}',ERPSequence='{5}',ERPUpload='1'
  905. FROM ICSWareHouseLotInfoLog a
  906. INNER JOIN ICSTransfer c ON a.TransCode=c.TransferNO AND a.TransSequence=c.Sequence AND a.WorkPoint=c.WorkPoint
  907. WHERE c.TransferID='{0}' AND a.Identification='{1}' AND ERPUpload='0' AND c.Type='1'
  908. ";
  909. }
  910. //两步调出
  911. else if (TransType == TransTypeEnum.TwoStepTransferDocOut.GetDescription())
  912. {
  913. ERPupdate = @"UPDATE a set ERPID='{2}',ERPDetailID='{3}',ERPCode='{4}',ERPSequence='{5}',ERPUpload='1'
  914. FROM ICSWareHouseLotInfoLog a
  915. INNER JOIN ICSOtherOut c ON a.TransCode=c.OutCode AND a.TransSequence=c.Sequence AND a.WorkPoint=c.WorkPoint
  916. INNER JOIN ICSTransfer d ON c.TransferDetailID=d.TransferDetailID AND c.WorkPoint=d.WorkPoint
  917. WHERE c.OutID='{0}' AND a.Identification='{1}' AND ERPUpload='0'
  918. ";
  919. }
  920. //两步调入
  921. else if (TransType == TransTypeEnum.TwoStepTransferDocIn.GetDescription())
  922. {
  923. ERPupdate = @"UPDATE a set ERPID='{2}',ERPDetailID='{3}',ERPCode='{4}',ERPSequence='{5}',ERPUpload='1'
  924. FROM ICSWareHouseLotInfoLog a
  925. INNER JOIN ICSOtherIn b ON a.TransCode=b.InCode AND a.TransSequence=b.Sequence AND a.WorkPoint=b.WorkPoint
  926. INNER JOIN ICSTransfer c ON b.TransferDetailID=c.TransferDetailID AND b.WorkPoint=c.WorkPoint
  927. WHERE b.InID='{0}' AND a.Identification='{1}' AND ERPUpload='0'
  928. ";
  929. }
  930. //销售退货-原条码
  931. else if (TransType == TransTypeEnum.SalesReturnBack.GetDescription())
  932. {
  933. ERPupdate = @"UPDATE a set ERPID='{2}',ERPDetailID='{3}',ERPCode='{4}',ERPSequence='{5}',ERPUpload='1'
  934. FROM ICSWareHouseLotInfoLog a
  935. INNER JOIN ICSSDN c ON a.TransCode=c.SDNCode AND a.TransSequence=c.Sequence AND a.WorkPoint=c.WorkPoint
  936. WHERE c.SDNDetailID='{0}' AND a.Identification='{1}' AND ERPUpload='0' AND c.Type='2'
  937. ";
  938. }
  939. //其他出库
  940. else if (TransType == TransTypeEnum.OtherOutDoc.GetDescription())
  941. {
  942. ERPupdate = @"UPDATE a set ERPID='{2}',ERPDetailID='{3}',ERPCode='{4}',ERPSequence='{5}',ERPUpload='1'
  943. FROM ICSWareHouseLotInfoLog a
  944. INNER JOIN ICSOtherOut c ON a.TransCode=c.OutCode AND a.TransSequence=c.Sequence AND a.WorkPoint=c.WorkPoint
  945. WHERE c.OutID='{0}' AND a.Identification='{1}' AND ERPUpload='0'
  946. ";
  947. }
  948. //其他入库
  949. else if (TransType == TransTypeEnum.OtherInDoc.GetDescription())
  950. {
  951. ERPupdate = @"UPDATE a set ERPID='{2}',ERPDetailID='{3}',ERPCode='{4}',ERPSequence='{5}',ERPUpload='1'
  952. FROM ICSWareHouseLotInfoLog a
  953. INNER JOIN ICSInventoryLotDetail b ON a.LotNo=b.LotNo AND a.WorkPoint=b.WorkPoint
  954. INNER JOIN ICSOtherIn c ON b.TransCode=c.InCode AND b.TransSequence=c.Sequence AND b.WorkPoint=c.WorkPoint
  955. WHERE c.InID='{0}' AND a.Identification='{1}' AND ERPUpload='0'
  956. ";
  957. }
  958. //拆卸单
  959. else if (TransType == TransTypeEnum.DisassemblyDoc.GetDescription())
  960. {
  961. ERPupdate = @"UPDATE d set ERPID='{2}',ERPDetailID='{3}',ERPCode='{4}',ERPSequence='{5}',ERPUpload='1'
  962. FROM ICSWareHouseLotInfoLog a
  963. INNER JOIN ICSInventoryLotDetail b ON a.LotNo=b.LotNo AND a.WorkPoint=b.WorkPoint
  964. INNER JOIN ICSDisassemblyDoc c ON b.TransCode=c.DABDOCCode AND b.TransSequence=c.Sequence AND b.WorkPoint=c.WorkPoint
  965. INNER JOIN ICSWareHouseLotInfoLog d ON b.TransCode=d.TransCode AND d.TransSequence='1' AND b.WorkPoint=d.WorkPoint
  966. WHERE c.DABDOCID='{0}' AND a.Identification='{1}' AND d.ERPUpload='0'
  967. UPDATE a set ERPID='{2}',ERPDetailID='{3}',ERPCode='{4}',ERPSequence='{5}',ERPUpload='1'
  968. FROM ICSWareHouseLotInfoLog a
  969. INNER JOIN ICSInventoryLotDetail b ON a.LotNo=b.LotNo AND a.WorkPoint=b.WorkPoint
  970. INNER JOIN ICSDisassemblyDoc c ON b.TransCode=c.DABDOCCode AND b.TransSequence=c.Sequence AND b.WorkPoint=c.WorkPoint
  971. WHERE c.DABDOCID='{0}' AND a.Identification='{1}' AND ERPUpload='0' AND c.DABDOCType='2'
  972. ";
  973. }
  974. //领料申请单
  975. else if (TransType == TransTypeEnum.MOApply.GetDescription())
  976. {
  977. ERPupdate = @"UPDATE a set ERPID='{2}',ERPDetailID='{3}',ERPCode='{4}',ERPSequence='{5}',ERPUpload='1'
  978. FROM ICSWareHouseLotInfoLog a
  979. INNER JOIN ICSMOApply c ON a.TransCode=c.ApplyCode AND a.TransSequence=c.Sequence AND a.WorkPoint=c.WorkPoint
  980. WHERE c.ApplyDetailID='{0}' AND a.Identification='{1}' AND ERPUpload='0'
  981. ";
  982. }
  983. //委外领料申请单
  984. else if (TransType == TransTypeEnum.OOApply.GetDescription())
  985. {
  986. ERPupdate = @"UPDATE a set ERPID='{2}',ERPDetailID='{3}',ERPCode='{4}',ERPSequence='{5}',ERPUpload='1'
  987. FROM ICSWareHouseLotInfoLog a
  988. INNER JOIN ICSOApply c ON a.TransCode=c.ApplyCode AND a.TransSequence=c.Sequence AND a.WorkPoint=c.WorkPoint
  989. WHERE c.ApplyDetailID='{0}' AND a.Identification='{1}' AND ERPUpload='0'
  990. ";
  991. }
  992. //开立材料出库
  993. else if (TransType == TransTypeEnum.MOIssue.GetDescription())
  994. {
  995. ERPupdate = @"UPDATE a set ERPID='{2}',ERPDetailID='{3}',ERPCode='{4}',ERPSequence='{5}',ERPUpload='1'
  996. FROM ICSWareHouseLotInfoLog a
  997. INNER JOIN ICSMOIssue c ON a.TransCode=c.IssueCode AND a.TransSequence=c.Sequence AND a.WorkPoint=c.WorkPoint
  998. WHERE c.IssueID='{0}' AND a.Identification='{1}' AND ERPUpload='0'
  999. ";
  1000. }
  1001. //开立委外材料出库
  1002. else if (TransType == TransTypeEnum.OOIssue.GetDescription())
  1003. {
  1004. ERPupdate = @"UPDATE a set ERPID='{2}',ERPDetailID='{3}',ERPCode='{4}',ERPSequence='{5}',ERPUpload='1'
  1005. FROM ICSWareHouseLotInfoLog a
  1006. INNER JOIN ICSOIssue c ON a.TransCode=c.IssueCode AND a.TransSequence=c.Sequence AND a.WorkPoint=c.WorkPoint
  1007. WHERE c.IssueID='{0}' AND a.Identification='{1}' AND ERPUpload='0'
  1008. ";
  1009. }
  1010. //开立红字入库单
  1011. else if (TransType == TransTypeEnum.PurchaseReceive.GetDescription())
  1012. {
  1013. ERPupdate = @"UPDATE a set ERPID='{2}',ERPDetailID='{3}',ERPCode='{4}',ERPSequence='{5}',ERPUpload='1'
  1014. FROM ICSWareHouseLotInfoLog a
  1015. INNER JOIN ICSPurchaseReceive c ON a.TransCode=c.RCVCode AND a.TransSequence=c.Sequence AND a.WorkPoint=c.WorkPoint
  1016. WHERE c.RCVID='{0}' AND a.Identification='{1}' AND ERPUpload='0' AND c.Type='2'
  1017. ";
  1018. }
  1019. //开立委外红字入库单
  1020. else if (TransType == TransTypeEnum.OutsourcingReceiveDocNegative.GetDescription())
  1021. {
  1022. ERPupdate = @"UPDATE a set ERPID='{2}',ERPDetailID='{3}',ERPCode='{4}',ERPSequence='{5}',ERPUpload='1'
  1023. FROM ICSWareHouseLotInfoLog a
  1024. INNER JOIN ICSOutsourcingReceive c ON a.TransCode=c.RCVCode AND a.TransSequence=c.Sequence AND a.WorkPoint=c.WorkPoint
  1025. WHERE c.RCVID='{0}' AND a.Identification='{1}' AND ERPUpload='0' AND c.Type='2'
  1026. ";
  1027. }
  1028. //借用
  1029. else if (TransType == TransTypeEnum.BrrowDoc.GetDescription())
  1030. {
  1031. ERPupdate = @"UPDATE a set ERPID='{2}',ERPDetailID='{3}',ERPCode='{4}',ERPSequence='{5}',ERPUpload='1'
  1032. FROM ICSWareHouseLotInfoLog a
  1033. INNER JOIN ICSBrrow c ON a.TransCode=c.BrrowCode AND a.TransSequence=c.Sequence AND a.WorkPoint=c.WorkPoint
  1034. WHERE c.BrrowDetailID='{0}' AND a.Identification='{1}' AND ERPUpload='0'
  1035. ";
  1036. }
  1037. //归还
  1038. else if (TransType == TransTypeEnum.ReturnDoc.GetDescription())
  1039. {
  1040. ERPupdate = @"UPDATE a set ERPID='{2}',ERPDetailID='{3}',ERPCode='{4}',ERPSequence='{5}',ERPUpload='1'
  1041. FROM ICSWareHouseLotInfoLog a
  1042. INNER JOIN ICSInventoryLotDetail b ON a.LotNo=b.LotNo AND a.WorkPoint=b.WorkPoint
  1043. INNER JOIN ICSReturn c ON b.TransCode=c.ReturnCode AND b.TransSequence=c.Sequence AND b.WorkPoint=c.WorkPoint
  1044. WHERE c.ReturnDetailID='{0}' AND a.Identification='{1}' AND ERPUpload='0'
  1045. ";
  1046. }
  1047. ERPupdate = string.Format(ERPupdate, SourceDetailID, Identification, ID, DetailID, Code, Sequence);
  1048. if (!DBHelper.ExecuteNonQuery(ERPupdate, cmd))
  1049. {
  1050. throw new Exception(TransType + language.GetNameByCode("WMSAPIInfo175"));//"回写日志失败!");
  1051. }
  1052. }
  1053. catch (Exception ex)
  1054. {
  1055. log.Debug(ex.ToString());
  1056. log.Debug(TransType + Environment.NewLine + ERPupdate);
  1057. }
  1058. }
  1059. }
  1060. }