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

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