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.

2030 lines
118 KiB

3 weeks ago
  1. using NFine.Data.Extensions;
  2. using System;
  3. using NFine.Repository;
  4. using NFine.Domain._03_Entity.SRM;
  5. using Newtonsoft.Json;
  6. using Newtonsoft.Json.Linq;
  7. using System.Data;
  8. using System.Configuration;
  9. using System.Text;
  10. using System.Net;
  11. using System.IO;
  12. namespace NFine.Application.WMS
  13. {
  14. public class RevokeBusinessApp : RepositoryFactory<ICSVendor>
  15. {
  16. //采购入库撤销
  17. public string RevocationPurchase(string keyValue)
  18. {
  19. string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
  20. string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
  21. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  22. string msg = "";
  23. string sql = string.Empty;
  24. JArray res = (JArray)JsonConvert.DeserializeObject(keyValue);
  25. foreach (var item in res)
  26. {
  27. JObject jo = (JObject)item;
  28. sql += $@" if NOT EXISTS(SELECT Id FROM ICSWareHouseLotInfoLog WHERE WorkPoint='{WorkPoint}' AND Identification=(select top 1 a.Identification from dbo.ICSWareHouseLotInfoLog a
  29. where a.LotNo='{jo["LotNo"]}' and a.WorkPoint='{WorkPoint}' and isnull(EATTRIBUTE1,'')<>'1' order by a.MTIME desc) AND Identification='{jo["Identification"]}')
  30. BEGIN
  31. RAISERROR(',', 16, 1);
  32. RETURN
  33. END ;";
  34. sql += string.Format(@"delete from ICSWareHouseLotInfo where LotNo='{0}' and WorkPoint='{1}' ", jo["LotNo"].ToString(), WorkPoint);
  35. sql += string.Format(@"update ICSPurchaseOrder set InQuantity =InQuantity-'{0}' where POCode='{1}' and Sequence='{2}' and WorkPoint='{3}'", jo["Quantity"].ToString(), jo["TransCode"].ToString(), jo["TransSequence"].ToString(), WorkPoint);
  36. sql += string.Format(@"update ICSWareHouseLotInfoLog set EATTRIBUTE1 ='1' , EATTRIBUTE3=getdate(),EATTRIBUTE4='{0}',EATTRIBUTE5='{1}' where ID='{2}' and WorkPoint='{3}'", MUSER, MUSERNAME, jo["ID"].ToString(), WorkPoint);
  37. }
  38. try
  39. {
  40. if (SqlHelper.CmdExecuteNonQueryLi(sql) > 0)
  41. {
  42. }
  43. }
  44. catch (Exception ex)
  45. {
  46. msg = ex.Message;
  47. }
  48. return msg;
  49. }
  50. //采购入库-采购到货单撤销
  51. public string RevocationDeliveryNotice(string keyValue)
  52. {
  53. string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
  54. string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
  55. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  56. string msg = "";
  57. string sql = string.Empty;
  58. JArray res = (JArray)JsonConvert.DeserializeObject(keyValue);
  59. foreach (var item in res)
  60. {
  61. JObject jo = (JObject)item;
  62. sql += $@" if NOT EXISTS(SELECT Id FROM ICSWareHouseLotInfoLog WHERE WorkPoint='{WorkPoint}' AND Identification=(select top 1 a.Identification from dbo.ICSWareHouseLotInfoLog a
  63. where a.LotNo='{jo["LotNo"]}' and a.WorkPoint='{WorkPoint}' and isnull(EATTRIBUTE1,'')<>'1' order by a.MTIME desc) AND Identification='{jo["Identification"]}')
  64. BEGIN
  65. RAISERROR(',', 16, 1);
  66. RETURN
  67. END ;";
  68. sql += string.Format(@"delete from ICSWareHouseLotInfo where LotNo='{0}' and WorkPoint='{1}' ", jo["LotNo"].ToString(), WorkPoint);
  69. sql += string.Format(@"update ICSDeliveryNotice set RCVQuantity =RCVQuantity-'{0}' where DNCode='{1}' and Sequence='{2}' and WorkPoint='{3}' and DNType='1'", jo["Quantity"].ToString(), jo["TransCode"].ToString(), jo["TransSequence"].ToString(), WorkPoint);
  70. sql += string.Format(@"update ICSWareHouseLotInfoLog set EATTRIBUTE1 ='1' , EATTRIBUTE3=getdate(),EATTRIBUTE4='{0}',EATTRIBUTE5='{1}' where ID='{2}' and WorkPoint='{3}'", MUSER, MUSERNAME, jo["ID"].ToString(), WorkPoint);
  71. }
  72. try
  73. {
  74. if (SqlHelper.CmdExecuteNonQueryLi(sql) > 0)
  75. {
  76. }
  77. }
  78. catch (Exception ex)
  79. {
  80. msg = ex.Message;
  81. }
  82. return msg;
  83. }
  84. //生产订单备料表
  85. public string RevocationPicking(string keyValue)
  86. {
  87. string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
  88. string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
  89. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  90. string msg = "";
  91. string sql = string.Empty;
  92. JArray res = (JArray)JsonConvert.DeserializeObject(keyValue);
  93. foreach (var item in res)
  94. {
  95. JObject jo = (JObject)item;
  96. sql += $@" if NOT EXISTS(SELECT Id FROM ICSWareHouseLotInfoLog WHERE WorkPoint='{WorkPoint}' AND Identification=(select top 1 a.Identification from dbo.ICSWareHouseLotInfoLog a
  97. where a.LotNo='{jo["LotNo"]}' and a.WorkPoint='{WorkPoint}' and isnull(EATTRIBUTE1,'')<>'1' order by a.MTIME desc) AND Identification='{jo["Identification"]}')
  98. BEGIN
  99. RAISERROR(',', 16, 1);
  100. RETURN
  101. END ;";
  102. sql += $@" if NOT EXISTS(SELECT Id FROM ICSWareHouseLotInfoLog WHERE WorkPoint='{WorkPoint}' AND Identification=(select top 1 a.Identification from dbo.ICSWareHouseLotInfoLog a
  103. where a.LotNo='{jo["LotNo"]}' and a.WorkPoint='{WorkPoint}' and isnull(EATTRIBUTE1,'')<>'1' order by a.MTIME desc) AND Identification='{jo["Identification"]}')
  104. BEGIN
  105. RAISERROR(',', 16, 1);
  106. RETURN
  107. END ;";
  108. sql += string.Format(@"update ICSWareHouseLotInfo set Quantity=Quantity+ROUND('{0}' ,3),MTIME=getdate(),MUSER='{1}',MUSERName='{2}' where LotNo='{3}' and WorkPoint='{4}'", jo["Quantity"].ToString(), MUSER, MUSERNAME, jo["LotNo"].ToString(), WorkPoint);
  109. sql += string.Format(@"update a set IssueQuantity =IssueQuantity-'{0}' from ICSMOPick a left join ICSMO b on a.MODetailID=b.MODetailID and a.WorkPoint=b.WorkPoint
  110. where b.MOCode='{1}' and b.Sequence+'~'+a.Sequence='{2}' and a.WorkPoint='{3}'", jo["Quantity"].ToString(), jo["TransCode"].ToString(), jo["TransSequence"].ToString(), WorkPoint);
  111. sql += string.Format(@"update ICSWareHouseLotInfoLog set EATTRIBUTE1 ='1' , EATTRIBUTE3=getdate(),EATTRIBUTE4='{0}',EATTRIBUTE5='{1}' where ID='{2}' and WorkPoint='{3}'", MUSER, MUSERNAME, jo["ID"].ToString(), WorkPoint);
  112. }
  113. try
  114. {
  115. if (SqlHelper.CmdExecuteNonQueryLi(sql) > 0)
  116. {
  117. }
  118. }
  119. catch (Exception ex)
  120. {
  121. msg = ex.Message;
  122. }
  123. return msg;
  124. }
  125. //领料申请单
  126. public string RevocationMOApply(string keyValue)
  127. {
  128. string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
  129. string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
  130. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  131. string msg = "";
  132. string sql = string.Empty;
  133. JArray res = (JArray)JsonConvert.DeserializeObject(keyValue);
  134. foreach (var item in res)
  135. {
  136. JObject jo = (JObject)item;
  137. sql += $@" if NOT EXISTS(SELECT Id FROM ICSWareHouseLotInfoLog WHERE WorkPoint='{WorkPoint}' AND Identification=(select top 1 a.Identification from dbo.ICSWareHouseLotInfoLog a
  138. where a.LotNo='{jo["LotNo"]}' and a.WorkPoint='{WorkPoint}' and isnull(EATTRIBUTE1,'')<>'1' order by a.MTIME desc) AND Identification='{jo["Identification"]}')
  139. BEGIN
  140. RAISERROR(',', 16, 1);
  141. RETURN
  142. END ;";
  143. sql += string.Format(@"update ICSWareHouseLotInfo set Quantity=Quantity+'{0}',MTIME=getdate(),MUSER='{1}',MUSERName='{2}' where LotNo='{3}' and WorkPoint='{4}'", jo["Quantity"].ToString(), MUSER, MUSERNAME, jo["LotNo"].ToString(), WorkPoint);
  144. sql += string.Format(@"update ICSMOApply set IssueQuantity =IssueQuantity-'{0}' where ApplyCode='{1}' and Sequence='{2}' and WorkPoint='{3}' ", jo["Quantity"].ToString(), jo["TransCode"].ToString(), jo["TransSequence"].ToString(), WorkPoint);
  145. sql += string.Format(@"update ICSWareHouseLotInfoLog set EATTRIBUTE1 ='1' , EATTRIBUTE3=getdate(),EATTRIBUTE4='{0}',EATTRIBUTE5='{1}' where ID='{2}' and WorkPoint='{3}'", MUSER, MUSERNAME, jo["ID"].ToString(), WorkPoint);
  146. }
  147. try
  148. {
  149. if (SqlHelper.CmdExecuteNonQueryLi(sql) > 0)
  150. {
  151. }
  152. }
  153. catch (Exception ex)
  154. {
  155. msg = ex.Message;
  156. }
  157. return msg;
  158. }
  159. //材料出库
  160. public string RevocationMOIssue(string keyValue)
  161. {
  162. string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
  163. string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
  164. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  165. string msg = "";
  166. string sql = string.Empty;
  167. JArray res = (JArray)JsonConvert.DeserializeObject(keyValue);
  168. foreach (var item in res)
  169. {
  170. JObject jo = (JObject)item;
  171. sql += $@" if NOT EXISTS(SELECT Id FROM ICSWareHouseLotInfoLog WHERE WorkPoint='{WorkPoint}' AND Identification=(select top 1 a.Identification from dbo.ICSWareHouseLotInfoLog a
  172. where a.LotNo='{jo["LotNo"]}' and a.WorkPoint='{WorkPoint}' and isnull(EATTRIBUTE1,'')<>'1' order by a.MTIME desc) AND Identification='{jo["Identification"]}')
  173. BEGIN
  174. RAISERROR(',', 16, 1);
  175. RETURN
  176. END ;";
  177. sql += string.Format(@"update ICSWareHouseLotInfo set Quantity=Quantity+'{0}',MTIME=getdate(),MUSER='{1}',MUSERName='{2}' where LotNo='{3}' and WorkPoint='{4}'", jo["Quantity"].ToString(), MUSER, MUSERNAME, jo["LotNo"].ToString(), WorkPoint);
  178. sql += string.Format(@"update ICSMOIssue set IssueQuantity =IssueQuantity-'{0}' where IssueCode='{1}' and Sequence='{2}' and WorkPoint='{3}' and Type='1' and Status='2'", jo["Quantity"].ToString(), jo["TransCode"].ToString(), jo["TransSequence"].ToString(), WorkPoint);
  179. sql += string.Format(@"update ICSWareHouseLotInfoLog set EATTRIBUTE1 ='1' , EATTRIBUTE3=getdate(),EATTRIBUTE4='{0}',EATTRIBUTE5='{1}' where ID='{2}' and WorkPoint='{3}'", MUSER, MUSERNAME, jo["ID"].ToString(), WorkPoint);
  180. }
  181. try
  182. {
  183. if (SqlHelper.CmdExecuteNonQueryLi(sql) > 0)
  184. {
  185. }
  186. }
  187. catch (Exception ex)
  188. {
  189. msg = ex.Message;
  190. }
  191. return msg;
  192. }
  193. //产成品入库-生产订单
  194. public string RevocationFinished(string keyValue)
  195. {
  196. string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
  197. string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
  198. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  199. string msg = "";
  200. string sql = string.Empty;
  201. JArray res = (JArray)JsonConvert.DeserializeObject(keyValue);
  202. foreach (var item in res)
  203. {
  204. JObject jo = (JObject)item;
  205. sql += $@" if NOT EXISTS(SELECT Id FROM ICSWareHouseLotInfoLog WHERE WorkPoint='{WorkPoint}' AND Identification=(select top 1 a.Identification from dbo.ICSWareHouseLotInfoLog a
  206. where a.LotNo='{jo["LotNo"]}' and a.WorkPoint='{WorkPoint}' and isnull(EATTRIBUTE1,'')<>'1' order by a.MTIME desc) AND Identification='{jo["Identification"]}')
  207. BEGIN
  208. RAISERROR(',', 16, 1);
  209. RETURN
  210. END ;";
  211. sql += string.Format(@"delete from ICSWareHouseLotInfo where LotNo='{0}' and WorkPoint='{1}'", jo["LotNo"].ToString(), WorkPoint);
  212. sql += string.Format(@"update ICSMO set RCVQuantity =RCVQuantity-'{0}' where MOCode='{1}' and Sequence='{2}' and WorkPoint='{3}'", jo["Quantity"].ToString(), jo["TransCode"].ToString(), jo["TransSequence"].ToString(), WorkPoint);
  213. sql += string.Format(@"update ICSWareHouseLotInfoLog set EATTRIBUTE1 ='1' , EATTRIBUTE3=getdate(),EATTRIBUTE4='{0}',EATTRIBUTE5='{1}' where ID='{2}' and WorkPoint='{3}'", MUSER, MUSERNAME, jo["ID"].ToString(), WorkPoint);
  214. }
  215. try
  216. {
  217. if (SqlHelper.CmdExecuteNonQueryLi(sql) > 0)
  218. {
  219. }
  220. }
  221. catch (Exception ex)
  222. {
  223. msg = ex.Message;
  224. }
  225. return msg;
  226. }
  227. //产成品入库-产成品入库单
  228. public string RevocationManufactureReceive(string keyValue)
  229. {
  230. string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
  231. string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
  232. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  233. string msg = "";
  234. string sql = string.Empty;
  235. JArray res = (JArray)JsonConvert.DeserializeObject(keyValue);
  236. foreach (var item in res)
  237. {
  238. JObject jo = (JObject)item;
  239. sql += $@" if NOT EXISTS(SELECT Id FROM ICSWareHouseLotInfoLog WHERE WorkPoint='{WorkPoint}' AND Identification=(select top 1 a.Identification from dbo.ICSWareHouseLotInfoLog a
  240. where a.LotNo='{jo["LotNo"]}' and a.WorkPoint='{WorkPoint}' and isnull(EATTRIBUTE1,'')<>'1' order by a.MTIME desc) AND Identification='{jo["Identification"]}')
  241. BEGIN
  242. RAISERROR(',', 16, 1);
  243. RETURN
  244. END ;";
  245. sql += string.Format(@"delete from ICSWareHouseLotInfo where LotNo='{0}' and WorkPoint='{1}'", jo["LotNo"].ToString(), WorkPoint);
  246. sql += string.Format(@" update ICSManufactureReceive set RCVQuantity =RCVQuantity-'{0}' where RCVCode='{1}' and Sequence='{2}' and WorkPoint='{3}' and Type='1' ", jo["Quantity"].ToString(), jo["TransCode"].ToString(), jo["TransSequence"].ToString(), WorkPoint);
  247. sql += string.Format(@"update ICSWareHouseLotInfoLog set EATTRIBUTE1 ='1' , EATTRIBUTE3=getdate(),EATTRIBUTE4='{0}',EATTRIBUTE5='{1}' where ID='{2}' and WorkPoint='{3}'", MUSER, MUSERNAME, jo["ID"].ToString(), WorkPoint);
  248. }
  249. try
  250. {
  251. if (SqlHelper.CmdExecuteNonQueryLi(sql) > 0)
  252. {
  253. }
  254. }
  255. catch (Exception ex)
  256. {
  257. msg = ex.Message;
  258. }
  259. return msg;
  260. }
  261. //一步调拨
  262. public string RevocationICSTransfer(string keyValue)
  263. {
  264. string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
  265. string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
  266. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  267. string msg = "";
  268. string sql = string.Empty;
  269. JArray res = (JArray)JsonConvert.DeserializeObject(keyValue);
  270. foreach (var item in res)
  271. {
  272. JObject jo = (JObject)item;
  273. string sqlEnable = @"SELECT b.LotEnable FROM ICSInventoryLot a
  274. LEFT JOIN ICSInventory b ON a.InvCode=b.InvCode AND a.WorkPoint=b.WorkPoint
  275. where a.LotNo='{0}' and a.WorkPoint='{1}'";
  276. sqlEnable = string.Format(sqlEnable, jo["LotNo"].ToString(), WorkPoint);
  277. object Enable = SqlHelper.ExecuteScalar(sqlEnable);
  278. string sqlQty = @"select Quantity from dbo.ICSWareHouseLotInfo where LotNo='{0}' ";
  279. sqlQty = string.Format(sqlQty, jo["LotNo"].ToString());
  280. object Qty = SqlHelper.ExecuteScalar(sqlQty);
  281. sql += $@" if NOT EXISTS(SELECT Id FROM ICSWareHouseLotInfoLog WHERE WorkPoint='{WorkPoint}' AND Identification=(select top 1 a.Identification from dbo.ICSWareHouseLotInfoLog a
  282. where a.LotNo='{jo["LotNo"]}' and a.WorkPoint='{WorkPoint}' and isnull(EATTRIBUTE1,'')<>'1' order by a.MTIME desc) AND Identification='{jo["Identification"]}')
  283. BEGIN
  284. RAISERROR(',', 16, 1);
  285. RETURN
  286. END ;";
  287. if (Convert.ToBoolean(Enable) == true && (Convert.ToDecimal(Qty)-Convert.ToDecimal(jo["Quantity"].ToString())>0 ))
  288. {
  289. sql += string.Format(@"update ICSWareHouseLotInfo set Quantity=Quantity+'{0}',MTIME=getdate(),MUSER='{1}',MUSERName='{2}',WarehouseCode='{5}',LocationCode='{6}' where LotNo='{3}' and WorkPoint='{4}'", jo["Quantity"].ToString(), MUSER, MUSERNAME, jo["LotNo"].ToString(), WorkPoint, jo["FromWarehouseCode"].ToString(), jo["FromLocationCode"].ToString());
  290. }
  291. else
  292. {
  293. sql += string.Format(@"update ICSWareHouseLotInfo set MTIME=getdate(),MUSER='{0}',MUSERName='{1}',WarehouseCode='{4}',LocationCode='{5}' where LotNo='{2}' and WorkPoint='{3}'", MUSER, MUSERNAME, jo["LotNo"].ToString(), WorkPoint, jo["FromWarehouseCode"].ToString(), jo["FromLocationCode"].ToString());
  294. }
  295. sql += string.Format(@" update ICSTransfer set TransferQuantity =TransferQuantity-'{0}' where TransferNO='{1}' and Sequence='{2}' and WorkPoint='{3}' and Type='1' ", jo["Quantity"].ToString(), jo["TransCode"].ToString(), jo["TransSequence"].ToString(), WorkPoint);
  296. sql += string.Format(@"update ICSWareHouseLotInfoLog set EATTRIBUTE1 ='1' , EATTRIBUTE3=getdate(),EATTRIBUTE4='{0}',EATTRIBUTE5='{1}' where ID='{2}' and WorkPoint='{3}'", MUSER, MUSERNAME, jo["ID"].ToString(), WorkPoint);
  297. }
  298. try
  299. {
  300. if (SqlHelper.CmdExecuteNonQueryLi(sql) > 0)
  301. {
  302. }
  303. }
  304. catch (Exception ex)
  305. {
  306. msg = ex.Message;
  307. }
  308. return msg;
  309. }
  310. // u9跨组织调入(调拨单)
  311. public string RevocationKZZICSTransfer(string keyValue)
  312. {
  313. string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
  314. string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
  315. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  316. string msg = "";
  317. string sql = string.Empty;
  318. JArray res = (JArray)JsonConvert.DeserializeObject(keyValue);
  319. foreach (var item in res)
  320. {
  321. JObject jo = (JObject)item;
  322. string sqlSeach = @" select WorkPoint from ICSTransfer where TransferNO='"+ jo["TransCode"].ToString() + "' and Sequence='"+ jo["TransSequence"].ToString() + "'";
  323. object OldWorkPoint = SqlHelper.ExecuteScalar(sqlSeach);
  324. string sqlNewColspan = @" select b.Colspan from dbo.ICSInventoryLot a
  325. inner join dbo.ICSExtension b on a.ExtensionID=b.ID and a.WorkPoint=b.WorkPoint
  326. where a.LotNo='" + jo["LotNo"].ToString() + "' ";
  327. object NewColspan = SqlHelper.ExecuteScalar(sqlNewColspan);
  328. string sqlOldColspan = @"select ID from dbo.ICSExtension where WorkPoint='" + OldWorkPoint + "' and Colspan='" + NewColspan + "'";
  329. object OldID = SqlHelper.ExecuteScalar(sqlOldColspan);
  330. string sqlQty = @"select Quantity from dbo.ICSWareHouseLotInfo where LotNo='{0}' ";
  331. sqlQty = string.Format(sqlQty, jo["LotNo"].ToString());
  332. object Qty = SqlHelper.ExecuteScalar(sqlQty);
  333. sql += $@" if NOT EXISTS(SELECT Id FROM ICSWareHouseLotInfoLog WHERE WorkPoint='{WorkPoint}' AND Identification=(select top 1 a.Identification from dbo.ICSWareHouseLotInfoLog a
  334. where a.LotNo='{jo["LotNo"]}' and a.WorkPoint='{WorkPoint}' and isnull(EATTRIBUTE1,'')<>'1' order by a.MTIME desc) AND Identification='{jo["Identification"]}')
  335. BEGIN
  336. RAISERROR(',', 16, 1);
  337. RETURN
  338. END ;";
  339. sql += string.Format(@"update ICSWareHouseLotInfo set MTIME=getdate(),MUSER='{0}',MUSERName='{1}',WarehouseCode='{4}',LocationCode='{5}' ,WorkPoint='{6}' where LotNo='{2}' and WorkPoint='{3}'", MUSER, MUSERNAME, jo["LotNo"].ToString(), WorkPoint, jo["FromWarehouseCode"].ToString(), jo["FromLocationCode"].ToString(), OldWorkPoint);
  340. sql += string.Format(@"update ICSInventoryLot set WorkPoint='{0}' , ExtensionID='{2}' where LotNo='{1}'", OldWorkPoint, jo["LotNo"].ToString(), OldID);
  341. sql += string.Format(@"update ICSInventoryLotDetail set WorkPoint='{0}' where LotNo='{1}'", OldWorkPoint, jo["LotNo"].ToString());
  342. sql += string.Format(@" update ICSTransfer set TransferQuantity =TransferQuantity-'{0}' where TransferNO='{1}' and Sequence='{2}' and WorkPoint='{3}' ", jo["Quantity"].ToString(), jo["TransCode"].ToString(), jo["TransSequence"].ToString(), WorkPoint);
  343. sql += string.Format(@"update ICSWareHouseLotInfoLog set EATTRIBUTE1 ='1' , EATTRIBUTE3=getdate(),EATTRIBUTE4='{0}',EATTRIBUTE5='{1}' where ID='{2}' and WorkPoint='{3}'", MUSER, MUSERNAME, jo["ID"].ToString(), WorkPoint);
  344. }
  345. try
  346. {
  347. if (SqlHelper.CmdExecuteNonQueryLi(sql) > 0)
  348. {
  349. }
  350. }
  351. catch (Exception ex)
  352. {
  353. msg = ex.Message;
  354. }
  355. return msg;
  356. }
  357. //销售出库
  358. public string RevocationMarket(string keyValue)
  359. {
  360. string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
  361. string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
  362. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  363. string msg = "";
  364. string sql = string.Empty;
  365. JArray res = (JArray)JsonConvert.DeserializeObject(keyValue);
  366. foreach (var item in res)
  367. {
  368. JObject jo = (JObject)item;
  369. sql += $@" if NOT EXISTS(SELECT Id FROM ICSWareHouseLotInfoLog WHERE WorkPoint='{WorkPoint}' AND Identification=(select top 1 a.Identification from dbo.ICSWareHouseLotInfoLog a
  370. where a.LotNo='{jo["LotNo"]}' and a.WorkPoint='{WorkPoint}' and isnull(EATTRIBUTE1,'')<>'1' order by a.MTIME desc) AND Identification='{jo["Identification"]}')
  371. BEGIN
  372. RAISERROR(',', 16, 1);
  373. RETURN
  374. END ;";
  375. sql += string.Format(@"update ICSWareHouseLotInfo set Quantity=Quantity+'{0}',MTIME=getdate(),MUSER='{1}',MUSERName='{2}' where LotNo='{3}' and WorkPoint='{4}'", jo["Quantity"].ToString(), MUSER, MUSERNAME, jo["LotNo"].ToString(), WorkPoint);
  376. sql += string.Format(@" update ICSSDN set SDNQuantity =SDNQuantity-'{0}' , MTIME=getdate(),MUSER='{1}',MUSERName='{2}' where SDNCode='{3}' and Sequence='{4}' and WorkPoint='{5}'", jo["Quantity"].ToString(), MUSER, MUSERNAME, jo["TransCode"].ToString(), jo["TransSequence"].ToString(), WorkPoint);
  377. sql += string.Format(@"update ICSWareHouseLotInfoLog set EATTRIBUTE1 ='1' , EATTRIBUTE3=getdate(),EATTRIBUTE4='{0}',EATTRIBUTE5='{1}' where ID='{2}' and WorkPoint='{3}'", MUSER, MUSERNAME, jo["ID"].ToString(), WorkPoint);
  378. }
  379. try
  380. {
  381. if (SqlHelper.CmdExecuteNonQueryLi(sql) > 0)
  382. {
  383. }
  384. }
  385. catch (Exception ex)
  386. {
  387. msg = ex.Message;
  388. }
  389. return msg;
  390. }
  391. //生产退料-生产退料单
  392. public string RevocationProduceStripping(string keyValue)
  393. {
  394. string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
  395. string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
  396. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  397. string msg = "";
  398. string sql = string.Empty;
  399. JArray res = (JArray)JsonConvert.DeserializeObject(keyValue);
  400. foreach (var item in res)
  401. {
  402. JObject jo = (JObject)item;
  403. string sqlseach = @"select Type from dbo.ICSInventoryLot where LotNo='"+ jo["LotNo"].ToString() + "'";
  404. object LotNoType= SqlHelper.ExecuteScalar(sqlseach);
  405. //新增验证(2025.5.14)
  406. sql += $@" if NOT EXISTS(SELECT Id FROM ICSWareHouseLotInfoLog WHERE WorkPoint='{WorkPoint}' AND Identification=(select top 1 a.Identification from dbo.ICSWareHouseLotInfoLog a
  407. where a.LotNo='{jo["LotNo"]}' and a.WorkPoint='{WorkPoint}' and isnull(EATTRIBUTE1,'')<>'1' order by a.MTIME desc) AND Identification='{jo["Identification"]}')
  408. BEGIN
  409. RAISERROR(',', 16, 1);
  410. RETURN
  411. END ;";
  412. if (LotNoType.ToString()== "1")
  413. {
  414. //新条码退
  415. sql += string.Format(@"delete from ICSWareHouseLotInfo where LotNo='{0}' and WorkPoint='{1}'", jo["LotNo"].ToString(), WorkPoint);
  416. sql += string.Format(@" update ICSMOApplyNegDetail set IssueNegQuantity =IssueNegQuantity-'{0}' , MTIME=getdate(),MUSER='{1}',MUSERName='{2}' where ApplyNegCode='{3}' and Sequence='{4}' and WorkPoint='{5}'", jo["Quantity"].ToString(), MUSER, MUSERNAME, jo["TransCode"].ToString(), jo["TransSequence"].ToString(), WorkPoint);
  417. sql += string.Format(@"update ICSWareHouseLotInfoLog set EATTRIBUTE1 ='1' , EATTRIBUTE3=getdate(),EATTRIBUTE4='{0}',EATTRIBUTE5='{1}' where ID='{2}' and WorkPoint='{3}'", MUSER, MUSERNAME, jo["ID"].ToString(), WorkPoint);
  418. sql += string.Format(@" UPDATE e SET IssueQuantity=ISNULL(IssueQuantity,0)+'{2}'
  419. FROM ICSInventoryLot a
  420. INNER JOIN ICSInventoryLotDetail b ON a.LotNo=b.LotNo AND a.WorkPoint=b.WorkPoint
  421. INNER JOIN ICSMOApplyNegDetail c ON b.TransCode=c.ApplyNegCode AND b.TransSequence=c.Sequence AND b.WorkPoint=c.WorkPoint
  422. INNER JOIN ICSMOApplyNeg d ON c.ApplyNegCode=d.ApplyNegCode AND c.WorkPoint=d.WorkPoint
  423. INNER JOIN ICSMOPick e ON c.SourceDetailID=e.PickID AND c.WorkPoint=e.WorkPoint
  424. WHERE a.LotNo='{0}' AND a.WorkPoint='{1}' AND d.Type='1'", jo["LotNo"].ToString(), WorkPoint, jo["Quantity"].ToString());
  425. }
  426. else
  427. {
  428. sql += string.Format(@"update ICSWareHouseLotInfo set Quantity=Quantity-'{0}',MTIME=getdate(),MUSER='{1}',MUSERName='{2}' where LotNo='{3}' and WorkPoint='{4}'", jo["Quantity"].ToString(), MUSER, MUSERNAME, jo["LotNo"].ToString(), WorkPoint);
  429. // sql += string.Format(@" update ICSMOApplyNegDetail set IssueNegQuantity =IssueNegQuantity-'{0}' , MTIME=getdate(),MUSER='{1}',MUSERName='{2}' where ApplyNegCode='{3}' and Sequence='{4}' and WorkPoint='{5}'", jo["Quantity"].ToString(), MUSER, MUSERNAME, jo["TransCode"].ToString(), jo["TransSequence"].ToString(), WorkPoint);
  430. sql += string.Format(@"update ICSWareHouseLotInfoLog set EATTRIBUTE1 ='1' , EATTRIBUTE3=getdate(),EATTRIBUTE4='{0}',EATTRIBUTE5='{1}' where ID='{2}' and WorkPoint='{3}'", MUSER, MUSERNAME, jo["ID"].ToString(), WorkPoint);
  431. sql += string.Format(@"UPDATE c SET IssueQuantity=ISNULL(IssueQuantity,0)+'{2}'
  432. FROM ICSWareHouseLotInfoLog a
  433. INNER JOIN ICSMO b ON a.TransCode=b.MOCode AND a.WorkPoint=b.WorkPoint
  434. INNER JOIN ICSMOPick c ON b.MODetailID = c.MODetailID AND b.WorkPoint = c.WorkPoint AND a.TransSequence = b.Sequence + '~' + c.Sequence
  435. WHERE a.LotNo='{0}' AND a.WorkPoint='{1}' AND a.ID='{3}'", jo["LotNo"].ToString(), WorkPoint, jo["Quantity"].ToString(), jo["ID"].ToString());
  436. }
  437. }
  438. try
  439. {
  440. if (SqlHelper.CmdExecuteNonQueryLi(sql) > 0)
  441. {
  442. }
  443. }
  444. catch (Exception ex)
  445. {
  446. msg = ex.Message;
  447. }
  448. return msg;
  449. }
  450. //生产退料-生产退料单-领料申请单
  451. public string RevocationProduceStrippingLL(string keyValue)
  452. {
  453. string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
  454. string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
  455. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  456. string msg = "";
  457. string sql = string.Empty;
  458. JArray res = (JArray)JsonConvert.DeserializeObject(keyValue);
  459. foreach (var item in res)
  460. {
  461. JObject jo = (JObject)item;
  462. string sqlseach = @"select Type from dbo.ICSInventoryLot where LotNo='" + jo["LotNo"].ToString() + "'";
  463. object LotNoType = SqlHelper.ExecuteScalar(sqlseach);
  464. sql += $@" if NOT EXISTS(SELECT Id FROM ICSWareHouseLotInfoLog WHERE WorkPoint='{WorkPoint}' AND Identification=(select top 1 a.Identification from dbo.ICSWareHouseLotInfoLog a
  465. where a.LotNo='{jo["LotNo"]}' and a.WorkPoint='{WorkPoint}' and isnull(EATTRIBUTE1,'')<>'1' order by a.MTIME desc) AND Identification='{jo["Identification"]}')
  466. BEGIN
  467. RAISERROR(',', 16, 1);
  468. RETURN
  469. END ;";
  470. if (LotNoType.ToString() == "1")
  471. {
  472. //新条码退
  473. sql += string.Format(@"delete from ICSWareHouseLotInfo where LotNo='{0}' and WorkPoint='{1}'", jo["LotNo"].ToString(), WorkPoint);
  474. sql += string.Format(@" update ICSMOApplyNegDetail set IssueNegQuantity =IssueNegQuantity-'{0}' , MTIME=getdate(),MUSER='{1}',MUSERName='{2}' where SDNCode='{3}' and Sequence='{4}' and WorkPoint='{5}'", jo["Quantity"].ToString(), MUSER, MUSERNAME, jo["TransCode"].ToString(), jo["TransSequence"].ToString(), WorkPoint);
  475. sql += string.Format(@"update ICSWareHouseLotInfoLog set EATTRIBUTE1 ='1' , EATTRIBUTE3=getdate(),EATTRIBUTE4='{0}',EATTRIBUTE5='{1}' where ID='{2}' and WorkPoint='{3}'", MUSER, MUSERNAME, jo["ID"].ToString(), WorkPoint);
  476. sql += string.Format(@" UPDATE e SET IssueQuantity=ISNULL(IssueQuantity,0)+'{2}'
  477. FROM ICSInventoryLot a
  478. INNER JOIN ICSInventoryLotDetail b ON a.LotNo=b.LotNo AND a.WorkPoint=b.WorkPoint
  479. INNER JOIN ICSMOApplyNegDetail c ON b.TransCode=c.ApplyNegCode AND b.TransSequence=c.Sequence AND b.WorkPoint=c.WorkPoint
  480. INNER JOIN ICSMOApplyNeg d ON c.ApplyNegCode=d.ApplyNegCode AND c.WorkPoint=d.WorkPoint
  481. INNER JOIN ICSMOApply e ON c.SourceDetailID=e.ApplyDetailID AND c.WorkPoint=e.WorkPoint
  482. WHERE a.LotNo='{0}' AND a.WorkPoint='{1}' AND d.Type='2'", jo["LotNo"].ToString(), WorkPoint, jo["Quantity"].ToString());
  483. }
  484. else
  485. {
  486. sql += string.Format(@"update ICSWareHouseLotInfo set Quantity=Quantity-'{0}',MTIME=getdate(),MUSER='{1}',MUSERName='{2}' where LotNo='{3}' and WorkPoint='{4}'", jo["Quantity"].ToString(), MUSER, MUSERNAME, jo["LotNo"].ToString(), WorkPoint);
  487. // sql += string.Format(@" update ICSMOApplyNegDetail set IssueNegQuantity =IssueNegQuantity-'{0}' , MTIME=getdate(),MUSER='{1}',MUSERName='{2}' where SDNCode='{3}' and Sequence='{4}' and WorkPoint='{5}'", jo["Quantity"].ToString(), MUSER, MUSERNAME, jo["TransCode"].ToString(), jo["TransSequence"].ToString(), WorkPoint);
  488. sql += string.Format(@"update ICSWareHouseLotInfoLog set EATTRIBUTE1 ='1' , EATTRIBUTE3=getdate(),EATTRIBUTE4='{0}',EATTRIBUTE5='{1}' where ID='{2}' and WorkPoint='{3}'", MUSER, MUSERNAME, jo["ID"].ToString(), WorkPoint);
  489. sql += string.Format(@"UPDATE c SET IssueQuantity=ISNULL(IssueQuantity,0)+'{2}'
  490. FROM ICSWareHouseLotInfoLog a
  491. INNER JOIN ICSMOApply c ON a.TransCode=c.ApplyCode AND a.TransSequence=c.Sequence AND a.WorkPoint=c.WorkPoint
  492. WHERE a.LotNo='{0}' AND a.WorkPoint='{1}' AND a.ID='{3}'", jo["LotNo"].ToString(), WorkPoint, jo["Quantity"].ToString(), jo["ID"].ToString());
  493. }
  494. }
  495. try
  496. {
  497. if (SqlHelper.CmdExecuteNonQueryLi(sql) > 0)
  498. {
  499. }
  500. }
  501. catch (Exception ex)
  502. {
  503. msg = ex.Message;
  504. }
  505. return msg;
  506. }
  507. //生产退料-生产退料单-材料出库单
  508. public string RevocationProduceStrippingCLCK(string keyValue)
  509. {
  510. string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
  511. string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
  512. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  513. string msg = "";
  514. string sql = string.Empty;
  515. JArray res = (JArray)JsonConvert.DeserializeObject(keyValue);
  516. foreach (var item in res)
  517. {
  518. JObject jo = (JObject)item;
  519. string sqlseach = @"select Type from dbo.ICSInventoryLot where LotNo='" + jo["LotNo"].ToString() + "'";
  520. object LotNoType = SqlHelper.ExecuteScalar(sqlseach);
  521. sql += $@" if NOT EXISTS(SELECT Id FROM ICSWareHouseLotInfoLog WHERE WorkPoint='{WorkPoint}' AND Identification=(select top 1 a.Identification from dbo.ICSWareHouseLotInfoLog a
  522. where a.LotNo='{jo["LotNo"]}' and a.WorkPoint='{WorkPoint}' and isnull(EATTRIBUTE1,'')<>'1' order by a.MTIME desc) AND Identification='{jo["Identification"]}')
  523. BEGIN
  524. RAISERROR(',', 16, 1);
  525. RETURN
  526. END ;";
  527. if (LotNoType.ToString() == "1")
  528. {
  529. //新条码退
  530. sql += string.Format(@"delete from ICSWareHouseLotInfo where LotNo='{0}' and WorkPoint='{1}'", jo["LotNo"].ToString(), WorkPoint);
  531. sql += string.Format(@" update ICSMOApplyNegDetail set IssueNegQuantity =IssueNegQuantity-'{0}' , MTIME=getdate(),MUSER='{1}',MUSERName='{2}' where SDNCode='{3}' and Sequence='{4}' and WorkPoint='{5}'", jo["Quantity"].ToString(), MUSER, MUSERNAME, jo["TransCode"].ToString(), jo["TransSequence"].ToString(), WorkPoint);
  532. sql += string.Format(@"update ICSWareHouseLotInfoLog set EATTRIBUTE1 ='1' , EATTRIBUTE3=getdate(),EATTRIBUTE4='{0}',EATTRIBUTE5='{1}' where ID='{2}' and WorkPoint='{3}'", MUSER, MUSERNAME, jo["ID"].ToString(), WorkPoint);
  533. sql += string.Format(@" UPDATE e SET IssueQuantity=ISNULL(IssueQuantity,0)+'{2}'
  534. FROM ICSInventoryLot a
  535. INNER JOIN ICSInventoryLotDetail b ON a.LotNo=b.LotNo AND a.WorkPoint=b.WorkPoint
  536. INNER JOIN ICSMOApplyNegDetail c ON b.TransCode=c.ApplyNegCode AND b.TransSequence=c.Sequence AND b.WorkPoint=c.WorkPoint
  537. INNER JOIN ICSMOApplyNeg d ON c.ApplyNegCode=d.ApplyNegCode AND c.WorkPoint=d.WorkPoint
  538. INNER JOIN ICSMOIssue e ON c.SourceDetailID=e.IssueDetailID AND c.WorkPoint=e.WorkPoint
  539. WHERE a.LotNo='{0}' AND a.WorkPoint='{1}' AND d.Type='3'", jo["LotNo"].ToString(), WorkPoint, jo["Quantity"].ToString());
  540. }
  541. else
  542. {
  543. sql += string.Format(@"update ICSWareHouseLotInfo set Quantity=Quantity-'{0}',MTIME=getdate(),MUSER='{1}',MUSERName='{2}' where LotNo='{3}' and WorkPoint='{4}'", jo["Quantity"].ToString(), MUSER, MUSERNAME, jo["LotNo"].ToString(), WorkPoint);
  544. // sql += string.Format(@" update ICSMOApplyNegDetail set IssueNegQuantity =IssueNegQuantity-'{0}' , MTIME=getdate(),MUSER='{1}',MUSERName='{2}' where SDNCode='{3}' and Sequence='{4}' and WorkPoint='{5}'", jo["Quantity"].ToString(), MUSER, MUSERNAME, jo["TransCode"].ToString(), jo["TransSequence"].ToString(), WorkPoint);
  545. sql += string.Format(@"update ICSWareHouseLotInfoLog set EATTRIBUTE1 ='1' , EATTRIBUTE3=getdate(),EATTRIBUTE4='{0}',EATTRIBUTE5='{1}' where ID='{2}' and WorkPoint='{3}'", MUSER, MUSERNAME, jo["ID"].ToString(), WorkPoint);
  546. sql += string.Format(@"UPDATE c SET IssueQuantity=ISNULL(IssueQuantity,0)+'{2}'
  547. FROM ICSWareHouseLotInfoLog a
  548. INNER JOIN ICSMOIssue c ON a.TransCode=c.IssueCode AND a.TransSequence=c.Sequence AND a.WorkPoint=c.WorkPoint
  549. WHERE a.LotNo='{0}' AND a.WorkPoint='{1}' AND a.ID='{3}'", jo["LotNo"].ToString(), WorkPoint, jo["Quantity"].ToString(), jo["ID"].ToString());
  550. }
  551. }
  552. try
  553. {
  554. if (SqlHelper.CmdExecuteNonQueryLi(sql) > 0)
  555. {
  556. }
  557. }
  558. catch (Exception ex)
  559. {
  560. msg = ex.Message;
  561. }
  562. return msg;
  563. }
  564. //其他出库(杂发)
  565. public string RevocationOtheOutboundr(string keyValue)
  566. {
  567. string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
  568. string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
  569. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  570. string msg = "";
  571. string sql = string.Empty;
  572. JArray res = (JArray)JsonConvert.DeserializeObject(keyValue);
  573. foreach (var item in res)
  574. {
  575. JObject jo = (JObject)item;
  576. sql += $@" if NOT EXISTS(SELECT Id FROM ICSWareHouseLotInfoLog WHERE WorkPoint='{WorkPoint}' AND Identification=(select top 1 a.Identification from dbo.ICSWareHouseLotInfoLog a
  577. where a.LotNo='{jo["LotNo"]}' and a.WorkPoint='{WorkPoint}' and isnull(EATTRIBUTE1,'')<>'1' order by a.MTIME desc) AND Identification='{jo["Identification"]}')
  578. BEGIN
  579. RAISERROR(',', 16, 1);
  580. RETURN
  581. END ;";
  582. sql += string.Format(@"update ICSWareHouseLotInfo set Quantity=Quantity+'{0}',MTIME=getdate(),MUSER='{1}',MUSERName='{2}' where LotNo='{3}' and WorkPoint='{4}'", jo["Quantity"].ToString(), MUSER, MUSERNAME, jo["LotNo"].ToString(), WorkPoint);
  583. sql += string.Format(@" update ICSOtherOut set OutQuantity =OutQuantity-'{0}' , MTIME=getdate(),MUSER='{1}',MUSERName='{2}' where OutCode='{3}' and Sequence='{4}' and WorkPoint='{5}'", jo["Quantity"].ToString(), MUSER, MUSERNAME, jo["TransCode"].ToString(), jo["TransSequence"].ToString(), WorkPoint);
  584. sql += string.Format(@"update ICSWareHouseLotInfoLog set EATTRIBUTE1 ='1' , MTIME=getdate(),MUSER='{0}',MUSERName='{1}' where ID='{2}' and WorkPoint='{3}'", MUSER, MUSERNAME, jo["ID"].ToString(), WorkPoint);
  585. }
  586. try
  587. {
  588. if (SqlHelper.CmdExecuteNonQueryLi(sql) > 0)
  589. {
  590. }
  591. }
  592. catch (Exception ex)
  593. {
  594. msg = ex.Message;
  595. }
  596. return msg;
  597. }
  598. //其他入库(杂收)
  599. public string RevocationOtheWarehousing(string keyValue)
  600. {
  601. string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
  602. string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
  603. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  604. string msg = "";
  605. string sql = string.Empty;
  606. JArray res = (JArray)JsonConvert.DeserializeObject(keyValue);
  607. foreach (var item in res)
  608. {
  609. JObject jo = (JObject)item;
  610. sql += $@" if NOT EXISTS(SELECT Id FROM ICSWareHouseLotInfoLog WHERE WorkPoint='{WorkPoint}' AND Identification=(select top 1 a.Identification from dbo.ICSWareHouseLotInfoLog a
  611. where a.LotNo='{jo["LotNo"]}' and a.WorkPoint='{WorkPoint}' and isnull(EATTRIBUTE1,'')<>'1' order by a.MTIME desc) AND Identification='{jo["Identification"]}')
  612. BEGIN
  613. RAISERROR(',', 16, 1);
  614. RETURN
  615. END ;";
  616. sql += string.Format(@"delete from ICSWareHouseLotInfo where LotNo='{0}' and WorkPoint='{1}'", jo["LotNo"].ToString(), WorkPoint);
  617. sql += string.Format(@" update ICSOtherIn set InQuantity =InQuantity-'{0}' where InCode='{1}' and Sequence='{2}' and WorkPoint='{3}' ", jo["Quantity"].ToString(), jo["TransCode"].ToString(), jo["TransSequence"].ToString(), WorkPoint);
  618. sql += string.Format(@"update ICSWareHouseLotInfoLog set EATTRIBUTE1 ='1' , MTIME=getdate(),MUSER='{0}',MUSERName='{1}' where ID='{2}' and WorkPoint='{3}'", MUSER, MUSERNAME, jo["ID"].ToString(), WorkPoint);
  619. }
  620. try
  621. {
  622. if (SqlHelper.CmdExecuteNonQueryLi(sql) > 0)
  623. {
  624. }
  625. }
  626. catch (Exception ex)
  627. {
  628. msg = ex.Message;
  629. }
  630. return msg;
  631. }
  632. //借用单
  633. public string RevocationBrrow(string keyValue)
  634. {
  635. string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
  636. string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
  637. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  638. string msg = "";
  639. string sql = string.Empty;
  640. JArray res = (JArray)JsonConvert.DeserializeObject(keyValue);
  641. foreach (var item in res)
  642. {
  643. JObject jo = (JObject)item;
  644. sql += $@" if NOT EXISTS(SELECT Id FROM ICSWareHouseLotInfoLog WHERE WorkPoint='{WorkPoint}' AND Identification=(select top 1 a.Identification from dbo.ICSWareHouseLotInfoLog a
  645. where a.LotNo='{jo["LotNo"]}' and a.WorkPoint='{WorkPoint}' and isnull(EATTRIBUTE1,'')<>'1' order by a.MTIME desc) AND Identification='{jo["Identification"]}')
  646. BEGIN
  647. RAISERROR(',', 16, 1);
  648. RETURN
  649. END ;";
  650. sql += string.Format(@"update ICSWareHouseLotInfo set Quantity=Quantity+'{0}',MTIME=getdate(),MUSER='{1}',MUSERName='{2}' where LotNo='{3}' and WorkPoint='{4}' ;", jo["Quantity"].ToString(), MUSER, MUSERNAME, jo["LotNo"].ToString(), WorkPoint);
  651. sql += string.Format(@" update ICSBrrow set BrrowQuantity =BrrowQuantity-'{0}' , MTIME=getdate(),MUSER='{1}',MUSERName='{2}' where BrrowCode='{3}' and Sequence='{4}' and WorkPoint='{5}' ;", jo["Quantity"].ToString(), MUSER, MUSERNAME, jo["TransCode"].ToString(), jo["TransSequence"].ToString(), WorkPoint);
  652. sql += string.Format(@"update ICSWareHouseLotInfoLog set EATTRIBUTE1 ='1' , MTIME=getdate(),MUSER='{0}',MUSERName='{1}' where ID='{2}' and WorkPoint='{3}'", MUSER, MUSERNAME, jo["ID"].ToString(), WorkPoint);
  653. }
  654. try
  655. {
  656. if (SqlHelper.CmdExecuteNonQueryLi(sql) > 0)
  657. {
  658. }
  659. }
  660. catch (Exception ex)
  661. {
  662. msg = ex.Message;
  663. }
  664. return msg;
  665. }
  666. //u9跨组织调出(调拨申请单)
  667. public string RevocationKZZICSTransferApplication(string keyValue)
  668. {
  669. string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
  670. string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
  671. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  672. string msg = "";
  673. string sql = string.Empty;
  674. JArray res = (JArray)JsonConvert.DeserializeObject(keyValue);
  675. foreach (var item in res)
  676. {
  677. JObject jo = (JObject)item;
  678. string sqlSeach = @" select WorkPoint from ICSTransferApplication where TransferNO='" + jo["TransCode"].ToString() + "' and Sequence='" + jo["TransSequence"].ToString() + "' and EATTRIBUTE30='"+ WorkPoint + "'";
  679. object OldWorkPoint = SqlHelper.ExecuteScalar(sqlSeach);
  680. string sqlNewColspan = @" select b.Colspan from dbo.ICSInventoryLot a
  681. inner join dbo.ICSExtension b on a.ExtensionID=b.ID and a.WorkPoint=b.WorkPoint
  682. where a.LotNo='"+ jo["LotNo"].ToString() + "' ";
  683. object NewColspan = SqlHelper.ExecuteScalar(sqlNewColspan);
  684. string sqlOldColspan = @"select ID from dbo.ICSExtension where WorkPoint='"+ OldWorkPoint + "' and Colspan='"+ NewColspan + "'";
  685. object OldID = SqlHelper.ExecuteScalar(sqlOldColspan);
  686. string sqlQty = @"select Quantity from dbo.ICSWareHouseLotInfo where LotNo='{0}' ";
  687. sqlQty = string.Format(sqlQty, jo["LotNo"].ToString());
  688. object Qty = SqlHelper.ExecuteScalar(sqlQty);
  689. sql += $@" if NOT EXISTS(SELECT Id FROM ICSWareHouseLotInfoLog WHERE WorkPoint='{WorkPoint}' AND Identification=(select top 1 a.Identification from dbo.ICSWareHouseLotInfoLog a
  690. where a.LotNo='{jo["LotNo"]}' and a.WorkPoint='{WorkPoint}' and isnull(EATTRIBUTE1,'')<>'1' order by a.MTIME desc) AND Identification='{jo["Identification"]}')
  691. BEGIN
  692. RAISERROR(',', 16, 1);
  693. RETURN
  694. END ;";
  695. sql += string.Format(@"update ICSWareHouseLotInfo set MTIME=getdate(),MUSER='{0}',MUSERName='{1}',WarehouseCode='{4}',LocationCode='{5}' ,WorkPoint='{6}' where LotNo='{2}' and WorkPoint='{3}'", MUSER, MUSERNAME, jo["LotNo"].ToString(), WorkPoint, jo["FromWarehouseCode"].ToString(), jo["FromLocationCode"].ToString(), OldWorkPoint);
  696. sql += string.Format(@"update ICSInventoryLot set WorkPoint='{0}' , ExtensionID='{2}' where LotNo='{1}'", OldWorkPoint, jo["LotNo"].ToString(), OldID);
  697. sql += string.Format(@"update ICSInventoryLotDetail set WorkPoint='{0}' where LotNo='{1}'", OldWorkPoint, jo["LotNo"].ToString());
  698. sql += string.Format(@" update ICSTransferApplication set TransferQuantity =TransferQuantity-'{0}' where TransferNO='{1}' and Sequence='{2}' and WorkPoint='{3}' and Type='1' ", jo["Quantity"].ToString(), jo["TransCode"].ToString(), jo["TransSequence"].ToString(), OldWorkPoint);
  699. sql += string.Format(@"update ICSWareHouseLotInfoLog set EATTRIBUTE1 ='1' , EATTRIBUTE3=getdate(),EATTRIBUTE4='{0}',EATTRIBUTE5='{1}' where ID='{2}' and WorkPoint='{3}'", MUSER, MUSERNAME, jo["ID"].ToString(), WorkPoint);
  700. }
  701. try
  702. {
  703. if (SqlHelper.CmdExecuteNonQueryLi(sql) > 0)
  704. {
  705. }
  706. }
  707. catch (Exception ex)
  708. {
  709. msg = ex.Message;
  710. }
  711. return msg;
  712. }
  713. //委外退料-委外退料单
  714. public string RevocationWWProduceStripping(string keyValue)
  715. {
  716. string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
  717. string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
  718. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  719. string msg = "";
  720. string sql = string.Empty;
  721. JArray res = (JArray)JsonConvert.DeserializeObject(keyValue);
  722. foreach (var item in res)
  723. {
  724. JObject jo = (JObject)item;
  725. string sqlseach = @"select Type from dbo.ICSInventoryLot where LotNo='" + jo["LotNo"].ToString() + "'";
  726. object LotNoType = SqlHelper.ExecuteScalar(sqlseach);
  727. sql += $@" if NOT EXISTS(SELECT Id FROM ICSWareHouseLotInfoLog WHERE WorkPoint='{WorkPoint}' AND Identification=(select top 1 a.Identification from dbo.ICSWareHouseLotInfoLog a
  728. where a.LotNo='{jo["LotNo"]}' and a.WorkPoint='{WorkPoint}' and isnull(EATTRIBUTE1,'')<>'1' order by a.MTIME desc) AND Identification='{jo["Identification"]}')
  729. BEGIN
  730. RAISERROR(',', 16, 1);
  731. RETURN
  732. END ;";
  733. if (LotNoType.ToString() == "1")
  734. {
  735. //新条码退
  736. sql += string.Format(@"delete from ICSWareHouseLotInfo where LotNo='{0}' and WorkPoint='{1}'", jo["LotNo"].ToString(), WorkPoint);
  737. sql += string.Format(@" update ICSOApplyNegDetail set IssueNegQuantity =IssueNegQuantity-'{0}' , MTIME=getdate(),MUSER='{1}',MUSERName='{2}' where SDNCode='{3}' and Sequence='{4}' and WorkPoint='{5}'", jo["Quantity"].ToString(), MUSER, MUSERNAME, jo["TransCode"].ToString(), jo["TransSequence"].ToString(), WorkPoint);
  738. sql += string.Format(@"update ICSWareHouseLotInfoLog set EATTRIBUTE1 ='1' where ID='{0}' and WorkPoint='{1}'", jo["ID"].ToString(), WorkPoint);
  739. sql += string.Format(@" UPDATE e SET IssueQuantity=ISNULL(IssueQuantity,0)+'{2}'
  740. FROM ICSInventoryLot a
  741. INNER JOIN ICSInventoryLotDetail b ON a.LotNo=b.LotNo AND a.WorkPoint=b.WorkPoint
  742. INNER JOIN ICSOApplyNegDetail c ON b.TransCode=c.OApplyNegCode AND b.TransSequence=c.Sequence AND b.WorkPoint=c.WorkPoint
  743. INNER JOIN ICSOApplyNeg d ON c.OApplyNegCode=d.OApplyNegCode AND c.WorkPoint=d.WorkPoint
  744. INNER JOIN ICSOOPick e ON c.SourceDetailID=e.PickID AND c.WorkPoint=e.WorkPoint
  745. WHERE a.LotNo='{0}' AND a.WorkPoint='{1}' AND d.Type='1'", jo["LotNo"].ToString(), WorkPoint, jo["Quantity"].ToString());
  746. }
  747. else
  748. {
  749. sql += string.Format(@"update ICSWareHouseLotInfo set Quantity=Quantity-'{0}',MUSER='{1}',MUSERName='{2}' where LotNo='{3}' and WorkPoint='{4}'", jo["Quantity"].ToString(), MUSER, MUSERNAME, jo["LotNo"].ToString(), WorkPoint);
  750. // sql += string.Format(@" update ICSMOApplyNegDetail set IssueNegQuantity =IssueNegQuantity-'{0}' , MTIME=getdate(),MUSER='{1}',MUSERName='{2}' where SDNCode='{3}' and Sequence='{4}' and WorkPoint='{5}'", jo["Quantity"].ToString(), MUSER, MUSERNAME, jo["TransCode"].ToString(), jo["TransSequence"].ToString(), WorkPoint);
  751. sql += string.Format(@"update ICSWareHouseLotInfoLog set EATTRIBUTE1 ='1' where ID='{0}' and WorkPoint='{1}'", jo["ID"].ToString(), WorkPoint);
  752. sql += string.Format(@"UPDATE c SET IssueQuantity=ISNULL(IssueQuantity,0)+'{2}'
  753. FROM ICSWareHouseLotInfoLog a
  754. INNER JOIN ICSOutsourcingOrder b ON a.TransCode=b.OOCode AND a.WorkPoint=b.WorkPoint
  755. INNER JOIN ICSMOPick c ON b.OODetailID = c.OODetailID AND b.WorkPoint = c.WorkPoint AND a.TransSequence = b.Sequence + '~' + c.Sequence
  756. WHERE a.LotNo='{0}' AND a.WorkPoint='{1}' AND a.ID='{3}'", jo["LotNo"].ToString(), WorkPoint, jo["Quantity"].ToString(), jo["ID"].ToString());
  757. }
  758. }
  759. try
  760. {
  761. if (SqlHelper.CmdExecuteNonQueryLi(sql) > 0)
  762. {
  763. }
  764. }
  765. catch (Exception ex)
  766. {
  767. msg = ex.Message;
  768. }
  769. return msg;
  770. }
  771. //委外退料-委外退料单-委外申请单
  772. public string RevocationWWProduceStrippingLL(string keyValue)
  773. {
  774. string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
  775. string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
  776. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  777. string msg = "";
  778. string sql = string.Empty;
  779. JArray res = (JArray)JsonConvert.DeserializeObject(keyValue);
  780. foreach (var item in res)
  781. {
  782. JObject jo = (JObject)item;
  783. string sqlseach = @"select Type from dbo.ICSInventoryLot where LotNo='" + jo["LotNo"].ToString() + "'";
  784. object LotNoType = SqlHelper.ExecuteScalar(sqlseach);
  785. sql += $@" if NOT EXISTS(SELECT Id FROM ICSWareHouseLotInfoLog WHERE WorkPoint='{WorkPoint}' AND Identification=(select top 1 a.Identification from dbo.ICSWareHouseLotInfoLog a
  786. where a.LotNo='{jo["LotNo"]}' and a.WorkPoint='{WorkPoint}' and isnull(EATTRIBUTE1,'')<>'1' order by a.MTIME desc) AND Identification='{jo["Identification"]}')
  787. BEGIN
  788. RAISERROR(',', 16, 1);
  789. RETURN
  790. END ;";
  791. if (LotNoType.ToString() == "1")
  792. {
  793. //新条码退
  794. sql += string.Format(@"delete from ICSWareHouseLotInfo where LotNo='{0}' and WorkPoint='{1}'", jo["LotNo"].ToString(), WorkPoint);
  795. sql += string.Format(@" update ICSOApplyNegDetail set IssueNegQuantity =IssueNegQuantity-'{0}' , MTIME=getdate(),MUSER='{1}',MUSERName='{2}' where SDNCode='{3}' and Sequence='{4}' and WorkPoint='{5}'", jo["Quantity"].ToString(), MUSER, MUSERNAME, jo["TransCode"].ToString(), jo["TransSequence"].ToString(), WorkPoint);
  796. sql += string.Format(@"update ICSWareHouseLotInfoLog set EATTRIBUTE1 ='1' where ID='{0}' and WorkPoint='{1}'", MUSER, MUSERNAME, jo["ID"].ToString(), WorkPoint);
  797. sql += string.Format(@" UPDATE e SET IssueQuantity=ISNULL(IssueQuantity,0)+'{2}'
  798. FROM ICSInventoryLot a
  799. INNER JOIN ICSInventoryLotDetail b ON a.LotNo=b.LotNo AND a.WorkPoint=b.WorkPoint
  800. INNER JOIN ICSOApplyNegDetail c ON b.TransCode=c.OApplyNegCode AND b.TransSequence=c.Sequence AND b.WorkPoint=c.WorkPoint
  801. INNER JOIN ICSOApplyNeg d ON c.OApplyNegCode=d.OApplyNegCode AND c.WorkPoint=d.WorkPoint
  802. INNER JOIN ICSOApply e ON c.SourceDetailID=e.ApplyDetailID AND c.WorkPoint=e.WorkPoint
  803. WHERE a.LotNo='{0}' AND a.WorkPoint='{1}' AND d.Type='2'", jo["LotNo"].ToString(), WorkPoint, jo["Quantity"].ToString());
  804. }
  805. else
  806. {
  807. sql += string.Format(@"update ICSWareHouseLotInfo set Quantity=Quantity-'{0}',MUSER='{1}',MUSERName='{2}' where LotNo='{3}' and WorkPoint='{4}'", jo["Quantity"].ToString(), MUSER, MUSERNAME, jo["LotNo"].ToString(), WorkPoint);
  808. // sql += string.Format(@" update ICSMOApplyNegDetail set IssueNegQuantity =IssueNegQuantity-'{0}' , MTIME=getdate(),MUSER='{1}',MUSERName='{2}' where SDNCode='{3}' and Sequence='{4}' and WorkPoint='{5}'", jo["Quantity"].ToString(), MUSER, MUSERNAME, jo["TransCode"].ToString(), jo["TransSequence"].ToString(), WorkPoint);
  809. sql += string.Format(@"update ICSWareHouseLotInfoLog set EATTRIBUTE1 ='1' where ID='{0}' and WorkPoint='{1}'", MUSER, MUSERNAME, jo["ID"].ToString(), WorkPoint);
  810. sql += string.Format(@"UPDATE c SET IssueQuantity=ISNULL(IssueQuantity,0)+'{2}'
  811. FROM ICSWareHouseLotInfoLog a
  812. INNER JOIN ICSOApply c ON a.TransCode=c.ApplyCode AND a.TransSequence=c.Sequence AND a.WorkPoint=c.WorkPoint
  813. WHERE a.LotNo='{0}' AND a.WorkPoint='{1}' AND a.ID='{3}'", jo["LotNo"].ToString(), WorkPoint, jo["Quantity"].ToString(), jo["ID"].ToString());
  814. }
  815. }
  816. try
  817. {
  818. if (SqlHelper.CmdExecuteNonQueryLi(sql) > 0)
  819. {
  820. }
  821. }
  822. catch (Exception ex)
  823. {
  824. msg = ex.Message;
  825. }
  826. return msg;
  827. }
  828. //委外退料-委外退料单-委外材料出库单
  829. public string RevocationWWProduceStrippingCLCK(string keyValue)
  830. {
  831. string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
  832. string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
  833. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  834. string msg = "";
  835. string sql = string.Empty;
  836. JArray res = (JArray)JsonConvert.DeserializeObject(keyValue);
  837. foreach (var item in res)
  838. {
  839. JObject jo = (JObject)item;
  840. string sqlseach = @"select Type from dbo.ICSInventoryLot where LotNo='" + jo["LotNo"].ToString() + "'";
  841. object LotNoType = SqlHelper.ExecuteScalar(sqlseach);
  842. sql += $@" if NOT EXISTS(SELECT Id FROM ICSWareHouseLotInfoLog WHERE WorkPoint='{WorkPoint}' AND Identification=(select top 1 a.Identification from dbo.ICSWareHouseLotInfoLog a
  843. where a.LotNo='{jo["LotNo"]}' and a.WorkPoint='{WorkPoint}' and isnull(EATTRIBUTE1,'')<>'1' order by a.MTIME desc) AND Identification='{jo["Identification"]}')
  844. BEGIN
  845. RAISERROR(',', 16, 1);
  846. RETURN
  847. END ;";
  848. if (LotNoType.ToString() == "1")
  849. {
  850. //新条码退
  851. sql += string.Format(@"delete from ICSWareHouseLotInfo where LotNo='{0}' and WorkPoint='{1}'", jo["LotNo"].ToString(), WorkPoint);
  852. sql += string.Format(@" update ICSMOApplyNegDetail set IssueNegQuantity =IssueNegQuantity-'{0}' , MTIME=getdate(),MUSER='{1}',MUSERName='{2}' where SDNCode='{3}' and Sequence='{4}' and WorkPoint='{5}'", jo["Quantity"].ToString(), MUSER, MUSERNAME, jo["TransCode"].ToString(), jo["TransSequence"].ToString(), WorkPoint);
  853. sql += string.Format(@"update ICSWareHouseLotInfoLog set EATTRIBUTE1 ='1' where ID='{0}' and WorkPoint='{1}'", MUSER, MUSERNAME, jo["ID"].ToString(), WorkPoint);
  854. sql += string.Format(@" UPDATE e SET IssueQuantity=ISNULL(IssueQuantity,0)+'{2}'
  855. FROM ICSInventoryLot a
  856. INNER JOIN ICSInventoryLotDetail b ON a.LotNo=b.LotNo AND a.WorkPoint=b.WorkPoint
  857. INNER JOIN ICSOApplyNegDetail c ON b.TransCode=c.OApplyNegCode AND b.TransSequence=c.Sequence AND b.WorkPoint=c.WorkPoint
  858. INNER JOIN ICSOApplyNeg d ON c.OApplyNegCode=d.OApplyNegCode AND c.WorkPoint=d.WorkPoint
  859. INNER JOIN ICSOIssue e ON c.SourceDetailID=e.IssueDetailID AND c.WorkPoint=e.WorkPoint
  860. WHERE a.LotNo='{0}' AND a.WorkPoint='{1}' AND d.Type='3'", jo["LotNo"].ToString(), WorkPoint, jo["Quantity"].ToString());
  861. }
  862. else
  863. {
  864. sql += string.Format(@"update ICSWareHouseLotInfo set Quantity=Quantity-'{0}',MTIME=getdate(),MUSER='{1}',MUSERName='{2}' where LotNo='{3}' and WorkPoint='{4}'", jo["Quantity"].ToString(), MUSER, MUSERNAME, jo["LotNo"].ToString(), WorkPoint);
  865. // sql += string.Format(@" update ICSMOApplyNegDetail set IssueNegQuantity =IssueNegQuantity-'{0}' , MTIME=getdate(),MUSER='{1}',MUSERName='{2}' where SDNCode='{3}' and Sequence='{4}' and WorkPoint='{5}'", jo["Quantity"].ToString(), MUSER, MUSERNAME, jo["TransCode"].ToString(), jo["TransSequence"].ToString(), WorkPoint);
  866. sql += string.Format(@"update ICSWareHouseLotInfoLog set EATTRIBUTE1 ='1' where ID='{0}' and WorkPoint='{1}'", MUSER, MUSERNAME, jo["ID"].ToString(), WorkPoint);
  867. sql += string.Format(@"UPDATE c SET IssueQuantity=ISNULL(IssueQuantity,0)+'{2}'
  868. FROM ICSWareHouseLotInfoLog a
  869. INNER JOIN ICSOIssue c ON a.TransCode=c.IssueCode AND a.TransSequence=c.Sequence AND a.WorkPoint=c.WorkPoint
  870. WHERE a.LotNo='{0}' AND a.WorkPoint='{1}' AND a.ID='{3}'", jo["LotNo"].ToString(), WorkPoint, jo["Quantity"].ToString(), jo["ID"].ToString());
  871. }
  872. }
  873. try
  874. {
  875. if (SqlHelper.CmdExecuteNonQueryLi(sql) > 0)
  876. {
  877. }
  878. }
  879. catch (Exception ex)
  880. {
  881. msg = ex.Message;
  882. }
  883. return msg;
  884. }
  885. //委外入库撤销
  886. public string RevocationWWPurchase(string keyValue)
  887. {
  888. string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
  889. string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
  890. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  891. string msg = "";
  892. string sql = string.Empty;
  893. JArray res = (JArray)JsonConvert.DeserializeObject(keyValue);
  894. foreach (var item in res)
  895. {
  896. JObject jo = (JObject)item;
  897. sql += $@" if NOT EXISTS(SELECT Id FROM ICSWareHouseLotInfoLog WHERE WorkPoint='{WorkPoint}' AND Identification=(select top 1 a.Identification from dbo.ICSWareHouseLotInfoLog a
  898. where a.LotNo='{jo["LotNo"]}' and a.WorkPoint='{WorkPoint}' and isnull(EATTRIBUTE1,'')<>'1' order by a.MTIME desc) AND Identification='{jo["Identification"]}')
  899. BEGIN
  900. RAISERROR(',', 16, 1);
  901. RETURN
  902. END ;";
  903. sql += string.Format(@"delete from ICSWareHouseLotInfo where LotNo='{0}' and WorkPoint='{1}' ", jo["LotNo"].ToString(), WorkPoint);
  904. sql += string.Format(@"update ICSOutsourcingOrder set InQuantity =InQuantity-'{0}' where OOCode='{1}' and Sequence='{2}' and WorkPoint='{3}'", jo["Quantity"].ToString(), jo["TransCode"].ToString(), jo["TransSequence"].ToString(), WorkPoint);
  905. sql += string.Format(@"update ICSWareHouseLotInfoLog set EATTRIBUTE1 ='1' , EATTRIBUTE3=getdate(),EATTRIBUTE4='{0}',EATTRIBUTE5='{1}' where ID='{2}' and WorkPoint='{3}'", MUSER, MUSERNAME, jo["ID"].ToString(), WorkPoint);
  906. }
  907. try
  908. {
  909. if (SqlHelper.CmdExecuteNonQueryLi(sql) > 0)
  910. {
  911. }
  912. }
  913. catch (Exception ex)
  914. {
  915. msg = ex.Message;
  916. }
  917. return msg;
  918. }
  919. public DataTable GetLogNewID(string LotNo)
  920. {
  921. string WorkPoints = NFine.Code.OperatorProvider.Provider.GetCurrent().Location.TrimEnd(',');
  922. string sql = @" select top 1 a.ID,a.Identification from dbo.ICSWareHouseLotInfoLog a
  923. where a.LotNo='{0}' and a.WorkPoint='{1}' and isnull(EATTRIBUTE1,'')<>'1'
  924. order by a.MTIME desc
  925. ";
  926. sql = string.Format(sql, LotNo, WorkPoints);
  927. DataTable dt = SqlHelper.GetDataTableBySql(sql);
  928. return dt;
  929. }
  930. public string RevocationPickingCPRKDC(string keyValue)
  931. {
  932. string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
  933. string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
  934. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  935. string msg = "";
  936. string sql = string.Empty;
  937. JArray res = (JArray)JsonConvert.DeserializeObject(keyValue);
  938. foreach (var item in res)
  939. {
  940. JObject jo = (JObject)item;
  941. sql += $@" if NOT EXISTS(SELECT Id FROM ICSWareHouseLotInfoLog WHERE WorkPoint='{WorkPoint}' AND Identification=(select top 1 a.Identification from dbo.ICSWareHouseLotInfoLog a
  942. where a.LotNo='{jo["LotNo"]}' and a.WorkPoint='{WorkPoint}' and isnull(EATTRIBUTE1,'')<>'1' order by a.MTIME desc) AND Identification='{jo["Identification"]}')
  943. BEGIN
  944. RAISERROR(',', 16, 1);
  945. RETURN
  946. END ;";
  947. sql += string.Format(@"update ICSWareHouseLotInfo set Quantity=Quantity+'{0}',MTIME=getdate(),MUSER='{1}',MUSERName='{2}' where LotNo='{3}' and WorkPoint='{4}'", jo["Quantity"].ToString(), MUSER, MUSERNAME, jo["LotNo"].ToString(), WorkPoint);
  948. sql += string.Format(@"update a set IssueQuantity =IssueQuantity-'{0}' from ICSMOPick a left join ICSMO b on a.MODetailID=b.MODetailID and a.WorkPoint=b.WorkPoint
  949. where b.MOCode='{1}' and b.Sequence+'~'+a.Sequence='{2}' and a.WorkPoint='{3}'", jo["Quantity"].ToString(), jo["TransCode"].ToString(), jo["TransSequence"].ToString(), WorkPoint);
  950. sql += string.Format(@"update ICSWareHouseLotInfoLog set EATTRIBUTE1 ='1' , EATTRIBUTE3=getdate(),EATTRIBUTE4='{0}',EATTRIBUTE5='{1}' where ID='{2}' and WorkPoint='{3}'", MUSER, MUSERNAME, jo["ID"].ToString(), WorkPoint);
  951. }
  952. try
  953. {
  954. if (SqlHelper.CmdExecuteNonQueryLi(sql) > 0)
  955. {
  956. }
  957. }
  958. catch (Exception ex)
  959. {
  960. msg = ex.Message;
  961. }
  962. return msg;
  963. }
  964. public string RevocationICSOOPickWWCPRKDC(string keyValue)
  965. {
  966. string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
  967. string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
  968. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  969. string msg = "";
  970. string sql = string.Empty;
  971. JArray res = (JArray)JsonConvert.DeserializeObject(keyValue);
  972. foreach (var item in res)
  973. {
  974. JObject jo = (JObject)item;
  975. sql += $@" if NOT EXISTS(SELECT Id FROM ICSWareHouseLotInfoLog WHERE WorkPoint='{WorkPoint}' AND Identification=(select top 1 a.Identification from dbo.ICSWareHouseLotInfoLog a
  976. where a.LotNo='{jo["LotNo"]}' and a.WorkPoint='{WorkPoint}' and isnull(EATTRIBUTE1,'')<>'1' order by a.MTIME desc) AND Identification='{jo["Identification"]}')
  977. BEGIN
  978. RAISERROR(',', 16, 1);
  979. RETURN
  980. END ;";
  981. sql += string.Format(@"update ICSWareHouseLotInfo set Quantity=Quantity+'{0}',MTIME=getdate(),MUSER='{1}',MUSERName='{2}' where LotNo='{3}' and WorkPoint='{4}'", jo["Quantity"].ToString(), MUSER, MUSERNAME, jo["LotNo"].ToString(), WorkPoint);
  982. sql += string.Format(@"update a set IssueQuantity =IssueQuantity-'{0}'
  983. from ICSOOPick a
  984. left join ICSOutsourcingOrder b on a.OODetailID=b.OODetailID and a.WorkPoint=b.WorkPoint
  985. where b.OOCode='{1}' and b.Sequence+'~'+a.Sequence='{2}' and a.WorkPoint='{3}'",
  986. jo["Quantity"].ToString(), jo["TransCode"].ToString(), jo["TransSequence"].ToString(), WorkPoint);
  987. sql += string.Format(@"update ICSWareHouseLotInfoLog set EATTRIBUTE1 ='1' , EATTRIBUTE3=getdate(),EATTRIBUTE4='{0}',EATTRIBUTE5='{1}' where ID='{2}' and WorkPoint='{3}'", MUSER, MUSERNAME, jo["ID"].ToString(), WorkPoint);
  988. }
  989. try
  990. {
  991. if (SqlHelper.CmdExecuteNonQueryLi(sql) > 0)
  992. {
  993. }
  994. }
  995. catch (Exception ex)
  996. {
  997. msg = ex.Message;
  998. }
  999. return msg;
  1000. }
  1001. public string RevocationWYTDB(string keyValue)
  1002. {
  1003. string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
  1004. string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
  1005. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  1006. string msg = "";
  1007. string sql = string.Empty;
  1008. JArray res = (JArray)JsonConvert.DeserializeObject(keyValue);
  1009. foreach (var item in res)
  1010. {
  1011. JObject jo = (JObject)item;
  1012. sql += $@" if NOT EXISTS(SELECT Id FROM ICSWareHouseLotInfoLog WHERE WorkPoint='{WorkPoint}' AND Identification=(select top 1 a.Identification from dbo.ICSWareHouseLotInfoLog a
  1013. where a.LotNo='{jo["LotNo"]}' and a.WorkPoint='{WorkPoint}' and isnull(EATTRIBUTE1,'')<>'1' order by a.MTIME desc) AND Identification='{jo["Identification"]}')
  1014. BEGIN
  1015. RAISERROR(',', 16, 1);
  1016. RETURN
  1017. END ;";
  1018. sql += string.Format(@"update ICSWareHouseLotInfo set MTIME=getdate(),MUSER='{1}',MUSERName='{2}',WarehouseCode='{5}',LocationCode='{6}' where LotNo='{3}' and WorkPoint='{4}'", jo["Quantity"].ToString(), MUSER, MUSERNAME, jo["LotNo"].ToString(), WorkPoint, jo["FromWarehouseCode"].ToString(), jo["FromLocationCode"].ToString());
  1019. sql += string.Format(@"update ICSWareHouseLotInfoLog set EATTRIBUTE1 ='1' , EATTRIBUTE3=getdate(),EATTRIBUTE4='{0}',EATTRIBUTE5='{1}' where ID='{2}' and WorkPoint='{3}'", MUSER, MUSERNAME, jo["ID"].ToString(), WorkPoint);
  1020. }
  1021. try
  1022. {
  1023. if (SqlHelper.CmdExecuteNonQueryLi(sql) > 0)
  1024. {
  1025. }
  1026. }
  1027. catch (Exception ex)
  1028. {
  1029. msg = ex.Message;
  1030. }
  1031. return msg;
  1032. }
  1033. public string RevocationWWDHRK(string keyValue)
  1034. {
  1035. string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
  1036. string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
  1037. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  1038. string msg = "";
  1039. string sql = string.Empty;
  1040. JArray res = (JArray)JsonConvert.DeserializeObject(keyValue);
  1041. foreach (var item in res)
  1042. {
  1043. JObject jo = (JObject)item;
  1044. sql += $@" if NOT EXISTS(SELECT Id FROM ICSWareHouseLotInfoLog WHERE WorkPoint='{WorkPoint}' AND Identification=(select top 1 a.Identification from dbo.ICSWareHouseLotInfoLog a
  1045. where a.LotNo='{jo["LotNo"]}' and a.WorkPoint='{WorkPoint}' and isnull(EATTRIBUTE1,'')<>'1' order by a.MTIME desc) AND Identification='{jo["Identification"]}')
  1046. BEGIN
  1047. RAISERROR(',', 16, 1);
  1048. RETURN
  1049. END ;";
  1050. sql += string.Format(@"delete from ICSWareHouseLotInfo where LotNo='{0}' and WorkPoint='{1}' ", jo["LotNo"].ToString(), WorkPoint);
  1051. sql += string.Format(@"update ICSODeliveryNotice set RCVQuantity =RCVQuantity-'{0}' where ODNCode='{1}' and Sequence='{2}' and WorkPoint='{3}' and DNType='1'", jo["Quantity"].ToString(), jo["TransCode"].ToString(), jo["TransSequence"].ToString(), WorkPoint);
  1052. sql += string.Format(@"update ICSWareHouseLotInfoLog set EATTRIBUTE1 ='1' , EATTRIBUTE3=getdate(),EATTRIBUTE4='{0}',EATTRIBUTE5='{1}' where ID='{2}' and WorkPoint='{3}'", MUSER, MUSERNAME, jo["ID"].ToString(), WorkPoint);
  1053. }
  1054. try
  1055. {
  1056. if (SqlHelper.CmdExecuteNonQueryLi(sql) > 0)
  1057. {
  1058. }
  1059. }
  1060. catch (Exception ex)
  1061. {
  1062. msg = ex.Message;
  1063. }
  1064. return msg;
  1065. }
  1066. public string RevocationWWTHWWTHD(string keyValue)
  1067. {
  1068. string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
  1069. string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
  1070. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  1071. string msg = "";
  1072. string sql = string.Empty;
  1073. JArray res = (JArray)JsonConvert.DeserializeObject(keyValue);
  1074. foreach (var item in res)
  1075. {
  1076. JObject jo = (JObject)item;
  1077. sql += $@" if NOT EXISTS(SELECT Id FROM ICSWareHouseLotInfoLog WHERE WorkPoint='{WorkPoint}' AND Identification=(select top 1 a.Identification from dbo.ICSWareHouseLotInfoLog a
  1078. where a.LotNo='{jo["LotNo"]}' and a.WorkPoint='{WorkPoint}' and isnull(EATTRIBUTE1,'')<>'1' order by a.MTIME desc) AND Identification='{jo["Identification"]}')
  1079. BEGIN
  1080. RAISERROR(',', 16, 1);
  1081. RETURN
  1082. END ;";
  1083. sql += string.Format(@"update ICSWareHouseLotInfo set Quantity=Quantity+'{0}',MTIME=getdate(),MUSER='{1}',MUSERName='{2}' where LotNo='{3}' and WorkPoint='{4}'", jo["Quantity"].ToString(), MUSER, MUSERNAME, jo["LotNo"].ToString(), WorkPoint);
  1084. sql += string.Format(@"update ICSODeliveryNotice set RCVQuantity =RCVQuantity-'{0}' where ODNCode='{1}' and Sequence='{2}' and WorkPoint='{3}' and ODNType='2' ", jo["Quantity"].ToString(), jo["TransCode"].ToString(), jo["TransSequence"].ToString(), WorkPoint);
  1085. sql += string.Format(@"update ICSWareHouseLotInfoLog set EATTRIBUTE1 ='1' , EATTRIBUTE3=getdate(),EATTRIBUTE4='{0}',EATTRIBUTE5='{1}' where ID='{2}' and WorkPoint='{3}'", MUSER, MUSERNAME, jo["ID"].ToString(), WorkPoint);
  1086. }
  1087. try
  1088. {
  1089. if (SqlHelper.CmdExecuteNonQueryLi(sql) > 0)
  1090. {
  1091. }
  1092. }
  1093. catch (Exception ex)
  1094. {
  1095. msg = ex.Message;
  1096. }
  1097. return msg;
  1098. }
  1099. public string RevocationWWTHHZRKD(string keyValue)
  1100. {
  1101. string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
  1102. string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
  1103. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  1104. string msg = "";
  1105. string sql = string.Empty;
  1106. JArray res = (JArray)JsonConvert.DeserializeObject(keyValue);
  1107. foreach (var item in res)
  1108. {
  1109. JObject jo = (JObject)item;
  1110. sql += $@" if NOT EXISTS(SELECT Id FROM ICSWareHouseLotInfoLog WHERE WorkPoint='{WorkPoint}' AND Identification=(select top 1 a.Identification from dbo.ICSWareHouseLotInfoLog a
  1111. where a.LotNo='{jo["LotNo"]}' and a.WorkPoint='{WorkPoint}' and isnull(EATTRIBUTE1,'')<>'1' order by a.MTIME desc) AND Identification='{jo["Identification"]}')
  1112. BEGIN
  1113. RAISERROR(',', 16, 1);
  1114. RETURN
  1115. END ;";
  1116. sql += string.Format(@"update ICSWareHouseLotInfo set Quantity=Quantity+'{0}',MTIME=getdate(),MUSER='{1}',MUSERName='{2}' where LotNo='{3}' and WorkPoint='{4}'", jo["Quantity"].ToString(), MUSER, MUSERNAME, jo["LotNo"].ToString(), WorkPoint);
  1117. sql += string.Format(@"update ICSOutsourcingReceive set RCVQuantity =RCVQuantity-'{0}' where RCVCode='{1}' and Sequence='{2}' and WorkPoint='{3}' and Type='2' ", jo["Quantity"].ToString(), jo["TransCode"].ToString(), jo["TransSequence"].ToString(), WorkPoint);
  1118. sql += string.Format(@"update ICSWareHouseLotInfoLog set EATTRIBUTE1 ='1' , EATTRIBUTE3=getdate(),EATTRIBUTE4='{0}',EATTRIBUTE5='{1}' where ID='{2}' and WorkPoint='{3}'", MUSER, MUSERNAME, jo["ID"].ToString(), WorkPoint);
  1119. }
  1120. try
  1121. {
  1122. if (SqlHelper.CmdExecuteNonQueryLi(sql) > 0)
  1123. {
  1124. }
  1125. }
  1126. catch (Exception ex)
  1127. {
  1128. msg = ex.Message;
  1129. }
  1130. return msg;
  1131. }
  1132. public string RevocationWWRK(string keyValue)
  1133. {
  1134. string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
  1135. string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
  1136. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  1137. string msg = "";
  1138. string sql = string.Empty;
  1139. JArray res = (JArray)JsonConvert.DeserializeObject(keyValue);
  1140. foreach (var item in res)
  1141. {
  1142. JObject jo = (JObject)item;
  1143. sql += $@" if NOT EXISTS(SELECT Id FROM ICSWareHouseLotInfoLog WHERE WorkPoint='{WorkPoint}' AND Identification=(select top 1 a.Identification from dbo.ICSWareHouseLotInfoLog a
  1144. where a.LotNo='{jo["LotNo"]}' and a.WorkPoint='{WorkPoint}' and isnull(EATTRIBUTE1,'')<>'1' order by a.MTIME desc) AND Identification='{jo["Identification"]}')
  1145. BEGIN
  1146. RAISERROR(',', 16, 1);
  1147. RETURN
  1148. END ;";
  1149. sql += string.Format(@"delete from ICSWareHouseLotInfo where LotNo='{0}' and WorkPoint='{1}' ", jo["LotNo"].ToString(), WorkPoint);
  1150. sql += string.Format(@"update ICSOutsourcingReceive set RCVQuantity =RCVQuantity-'{0}' where RCVCode='{1}' and Sequence='{2}' and WorkPoint='{3}' and Type='1' ", jo["Quantity"].ToString(), jo["TransCode"].ToString(), jo["TransSequence"].ToString(), WorkPoint);
  1151. sql += string.Format(@"update ICSWareHouseLotInfoLog set EATTRIBUTE1 ='1' , EATTRIBUTE3=getdate(),EATTRIBUTE4='{0}',EATTRIBUTE5='{1}' where ID='{2}' and WorkPoint='{3}'", MUSER, MUSERNAME, jo["ID"].ToString(), WorkPoint);
  1152. }
  1153. try
  1154. {
  1155. if (SqlHelper.CmdExecuteNonQueryLi(sql) > 0)
  1156. {
  1157. }
  1158. }
  1159. catch (Exception ex)
  1160. {
  1161. msg = ex.Message;
  1162. }
  1163. return msg;
  1164. }
  1165. public string RevocationCGTTHD(string keyValue)
  1166. {
  1167. string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
  1168. string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
  1169. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  1170. string msg = "";
  1171. string sql = string.Empty;
  1172. JArray res = (JArray)JsonConvert.DeserializeObject(keyValue);
  1173. foreach (var item in res)
  1174. {
  1175. JObject jo = (JObject)item;
  1176. sql += $@" if NOT EXISTS(SELECT Id FROM ICSWareHouseLotInfoLog WHERE WorkPoint='{WorkPoint}' AND Identification=(select top 1 a.Identification from dbo.ICSWareHouseLotInfoLog a
  1177. where a.LotNo='{jo["LotNo"]}' and a.WorkPoint='{WorkPoint}' and isnull(EATTRIBUTE1,'')<>'1' order by a.MTIME desc) AND Identification='{jo["Identification"]}')
  1178. BEGIN
  1179. RAISERROR(',', 16, 1);
  1180. RETURN
  1181. END ;";
  1182. sql += string.Format(@"update ICSWareHouseLotInfo set Quantity=Quantity+'{0}',MTIME=getdate(),MUSER='{1}',MUSERName='{2}' where LotNo='{3}' and WorkPoint='{4}'", jo["Quantity"].ToString(), MUSER, MUSERNAME, jo["LotNo"].ToString(), WorkPoint);
  1183. sql += string.Format(@"update ICSDeliveryNotice set RCVQuantity =RCVQuantity-'{0}' where DNCode='{1}' and Sequence='{2}' and WorkPoint='{3}' and DNType='2' ", jo["Quantity"].ToString(), jo["TransCode"].ToString(), jo["TransSequence"].ToString(), WorkPoint);
  1184. sql += string.Format(@"update ICSWareHouseLotInfoLog set EATTRIBUTE1 ='1' , EATTRIBUTE3=getdate(),EATTRIBUTE4='{0}',EATTRIBUTE5='{1}' where ID='{2}' and WorkPoint='{3}'", MUSER, MUSERNAME, jo["ID"].ToString(), WorkPoint);
  1185. }
  1186. try
  1187. {
  1188. if (SqlHelper.CmdExecuteNonQueryLi(sql) > 0)
  1189. {
  1190. }
  1191. }
  1192. catch (Exception ex)
  1193. {
  1194. msg = ex.Message;
  1195. }
  1196. return msg;
  1197. }
  1198. public string RevocationCGTHZRKD(string keyValue)
  1199. {
  1200. string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
  1201. string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
  1202. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  1203. string msg = "";
  1204. string sql = string.Empty;
  1205. JArray res = (JArray)JsonConvert.DeserializeObject(keyValue);
  1206. foreach (var item in res)
  1207. {
  1208. JObject jo = (JObject)item;
  1209. sql += $@" if NOT EXISTS(SELECT Id FROM ICSWareHouseLotInfoLog WHERE WorkPoint='{WorkPoint}' AND Identification=(select top 1 a.Identification from dbo.ICSWareHouseLotInfoLog a
  1210. where a.LotNo='{jo["LotNo"]}' and a.WorkPoint='{WorkPoint}' and isnull(EATTRIBUTE1,'')<>'1' order by a.MTIME desc) AND Identification='{jo["Identification"]}')
  1211. BEGIN
  1212. RAISERROR(',', 16, 1);
  1213. RETURN
  1214. END ;";
  1215. sql += string.Format(@"update ICSWareHouseLotInfo set Quantity=Quantity+'{0}',MTIME=getdate(),MUSER='{1}',MUSERName='{2}' where LotNo='{3}' and WorkPoint='{4}'", jo["Quantity"].ToString(), MUSER, MUSERNAME, jo["LotNo"].ToString(), WorkPoint);
  1216. sql += string.Format(@"update ICSPurchaseReceive set RCVQuantity =RCVQuantity-'{0}' where RCVCode='{1}' and Sequence='{2}' and WorkPoint='{3}' and Type='2' ", jo["Quantity"].ToString(), jo["TransCode"].ToString(), jo["TransSequence"].ToString(), WorkPoint);
  1217. sql += string.Format(@"update ICSWareHouseLotInfoLog set EATTRIBUTE1 ='1' , EATTRIBUTE3=getdate(),EATTRIBUTE4='{0}',EATTRIBUTE5='{1}' where ID='{2}' and WorkPoint='{3}'", MUSER, MUSERNAME, jo["ID"].ToString(), WorkPoint);
  1218. }
  1219. try
  1220. {
  1221. if (SqlHelper.CmdExecuteNonQueryLi(sql) > 0)
  1222. {
  1223. }
  1224. }
  1225. catch (Exception ex)
  1226. {
  1227. msg = ex.Message;
  1228. }
  1229. return msg;
  1230. }
  1231. public string RevocationXSTXSTHD(string keyValue)
  1232. {
  1233. string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
  1234. string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
  1235. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  1236. string msg = "";
  1237. string sql = string.Empty;
  1238. JArray res = (JArray)JsonConvert.DeserializeObject(keyValue);
  1239. foreach (var item in res)
  1240. {
  1241. JObject jo = (JObject)item;
  1242. sql += $@" if NOT EXISTS(SELECT Id FROM ICSWareHouseLotInfoLog WHERE WorkPoint='{WorkPoint}' AND Identification=(select top 1 a.Identification from dbo.ICSWareHouseLotInfoLog a
  1243. where a.LotNo='{jo["LotNo"]}' and a.WorkPoint='{WorkPoint}' and isnull(EATTRIBUTE1,'')<>'1' order by a.MTIME desc) AND Identification='{jo["Identification"]}')
  1244. BEGIN
  1245. RAISERROR(',', 16, 1);
  1246. RETURN
  1247. END ;";
  1248. sql += string.Format(@"delete from ICSWareHouseLotInfo where LotNo='{0}' and WorkPoint='{1}' ", jo["LotNo"].ToString(), WorkPoint);
  1249. sql += string.Format(@"update ICSSDN set SDNQuantity =SDNQuantity-'{0}' where SDNCode='{1}' and Sequence='{2}' and WorkPoint='{3}' and Type='2'", jo["Quantity"].ToString(), jo["TransCode"].ToString(), jo["TransSequence"].ToString(), WorkPoint);
  1250. sql += string.Format(@"update ICSWareHouseLotInfoLog set EATTRIBUTE1 ='1' , EATTRIBUTE3=getdate(),EATTRIBUTE4='{0}',EATTRIBUTE5='{1}' where ID='{2}' and WorkPoint='{3}'", MUSER, MUSERNAME, jo["ID"].ToString(), WorkPoint);
  1251. }
  1252. try
  1253. {
  1254. if (SqlHelper.CmdExecuteNonQueryLi(sql) > 0)
  1255. {
  1256. }
  1257. }
  1258. catch (Exception ex)
  1259. {
  1260. msg = ex.Message;
  1261. }
  1262. return msg;
  1263. }
  1264. public string RevocationWWFLBLB(string keyValue)
  1265. {
  1266. string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
  1267. string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
  1268. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  1269. string msg = "";
  1270. string sql = string.Empty;
  1271. JArray res = (JArray)JsonConvert.DeserializeObject(keyValue);
  1272. foreach (var item in res)
  1273. {
  1274. JObject jo = (JObject)item;
  1275. sql += $@" if NOT EXISTS(SELECT Id FROM ICSWareHouseLotInfoLog WHERE WorkPoint='{WorkPoint}' AND Identification=(select top 1 a.Identification from dbo.ICSWareHouseLotInfoLog a
  1276. where a.LotNo='{jo["LotNo"]}' and a.WorkPoint='{WorkPoint}' and isnull(EATTRIBUTE1,'')<>'1' order by a.MTIME desc) AND Identification='{jo["Identification"]}')
  1277. BEGIN
  1278. RAISERROR(',', 16, 1);
  1279. RETURN
  1280. END ;";
  1281. sql += string.Format(@"update ICSWareHouseLotInfo set Quantity=Quantity+'{0}',MTIME=getdate(),MUSER='{1}',MUSERName='{2}' where LotNo='{3}' and WorkPoint='{4}'", jo["Quantity"].ToString(), MUSER, MUSERNAME, jo["LotNo"].ToString(), WorkPoint);
  1282. sql += string.Format(@"update a set IssueQuantity =IssueQuantity-'{0}'
  1283. from ICSOOPick a
  1284. left join ICSOutsourcingOrder b on a.OODetailID=b.OODetailID and a.WorkPoint=b.WorkPoint
  1285. where b.OOCode='{1}' and b.Sequence+'~'+a.Sequence='{2}' and a.WorkPoint='{3}'",
  1286. jo["Quantity"].ToString(), jo["TransCode"].ToString(), jo["TransSequence"].ToString(), WorkPoint);
  1287. sql += string.Format(@"update ICSWareHouseLotInfoLog set EATTRIBUTE1 ='1' , EATTRIBUTE3=getdate(),EATTRIBUTE4='{0}',EATTRIBUTE5='{1}' where ID='{2}' and WorkPoint='{3}'", MUSER, MUSERNAME, jo["ID"].ToString(), WorkPoint);
  1288. }
  1289. try
  1290. {
  1291. if (SqlHelper.CmdExecuteNonQueryLi(sql) > 0)
  1292. {
  1293. }
  1294. }
  1295. catch (Exception ex)
  1296. {
  1297. msg = ex.Message;
  1298. }
  1299. return msg;
  1300. }
  1301. public string RevocationWWFLLLSQ(string keyValue)
  1302. {
  1303. string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
  1304. string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
  1305. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  1306. string msg = "";
  1307. string sql = string.Empty;
  1308. JArray res = (JArray)JsonConvert.DeserializeObject(keyValue);
  1309. foreach (var item in res)
  1310. {
  1311. JObject jo = (JObject)item;
  1312. sql += $@" if NOT EXISTS(SELECT Id FROM ICSWareHouseLotInfoLog WHERE WorkPoint='{WorkPoint}' AND Identification=(select top 1 a.Identification from dbo.ICSWareHouseLotInfoLog a
  1313. where a.LotNo='{jo["LotNo"]}' and a.WorkPoint='{WorkPoint}' and isnull(EATTRIBUTE1,'')<>'1' order by a.MTIME desc) AND Identification='{jo["Identification"]}')
  1314. BEGIN
  1315. RAISERROR(',', 16, 1);
  1316. RETURN
  1317. END ;";
  1318. sql += string.Format(@"update ICSWareHouseLotInfo set Quantity=Quantity+'{0}',MTIME=getdate(),MUSER='{1}',MUSERName='{2}' where LotNo='{3}' and WorkPoint='{4}'", jo["Quantity"].ToString(), MUSER, MUSERNAME, jo["LotNo"].ToString(), WorkPoint);
  1319. sql += string.Format(@"update ICSOApply set IssueQuantity =IssueQuantity-'{0}' where ApplyCode='{1}' and Sequence='{2}' and WorkPoint='{3}' ", jo["Quantity"].ToString(), jo["TransCode"].ToString(), jo["TransSequence"].ToString(), WorkPoint);
  1320. sql += string.Format(@"update ICSWareHouseLotInfoLog set EATTRIBUTE1 ='1' , EATTRIBUTE3=getdate(),EATTRIBUTE4='{0}',EATTRIBUTE5='{1}' where ID='{2}' and WorkPoint='{3}'", MUSER, MUSERNAME, jo["ID"].ToString(), WorkPoint);
  1321. }
  1322. try
  1323. {
  1324. if (SqlHelper.CmdExecuteNonQueryLi(sql) > 0)
  1325. {
  1326. }
  1327. }
  1328. catch (Exception ex)
  1329. {
  1330. msg = ex.Message;
  1331. }
  1332. return msg;
  1333. }
  1334. public string RevocationOOIssue(string keyValue)
  1335. {
  1336. string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
  1337. string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
  1338. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  1339. string msg = "";
  1340. string sql = string.Empty;
  1341. JArray res = (JArray)JsonConvert.DeserializeObject(keyValue);
  1342. foreach (var item in res)
  1343. {
  1344. JObject jo = (JObject)item;
  1345. sql += $@" if NOT EXISTS(SELECT Id FROM ICSWareHouseLotInfoLog WHERE WorkPoint='{WorkPoint}' AND Identification=(select top 1 a.Identification from dbo.ICSWareHouseLotInfoLog a
  1346. where a.LotNo='{jo["LotNo"]}' and a.WorkPoint='{WorkPoint}' and isnull(EATTRIBUTE1,'')<>'1' order by a.MTIME desc) AND Identification='{jo["Identification"]}')
  1347. BEGIN
  1348. RAISERROR(',', 16, 1);
  1349. RETURN
  1350. END ;";
  1351. sql += string.Format(@"update ICSWareHouseLotInfo set Quantity=Quantity+'{0}',MTIME=getdate(),MUSER='{1}',MUSERName='{2}' where LotNo='{3}' and WorkPoint='{4}'", jo["Quantity"].ToString(), MUSER, MUSERNAME, jo["LotNo"].ToString(), WorkPoint);
  1352. sql += string.Format(@"update ICSOIssue set IssueQuantity =IssueQuantity-'{0}' where IssueCode='{1}' and Sequence='{2}' and WorkPoint='{3}' and Type='1' and Status='2'", jo["Quantity"].ToString(), jo["TransCode"].ToString(), jo["TransSequence"].ToString(), WorkPoint);
  1353. sql += string.Format(@"update ICSWareHouseLotInfoLog set EATTRIBUTE1 ='1' , EATTRIBUTE3=getdate(),EATTRIBUTE4='{0}',EATTRIBUTE5='{1}' where ID='{2}' and WorkPoint='{3}'", MUSER, MUSERNAME, jo["ID"].ToString(), WorkPoint);
  1354. }
  1355. try
  1356. {
  1357. if (SqlHelper.CmdExecuteNonQueryLi(sql) > 0)
  1358. {
  1359. }
  1360. }
  1361. catch (Exception ex)
  1362. {
  1363. msg = ex.Message;
  1364. }
  1365. return msg;
  1366. }
  1367. public string DeleteERPLotLog(string keyValue)
  1368. {
  1369. string msg = "";
  1370. string APIURL = ConfigurationManager.ConnectionStrings["ERPAPIURL"].ConnectionString + "ERPLot/DELETE";
  1371. string result = HttpPost(APIURL, keyValue);
  1372. JObject Obj = (JObject)JsonConvert.DeserializeObject(result);//或者JObject jo = JObject.Parse(jsonText);
  1373. string MessAge = Obj["Message"].ToString();
  1374. string Success = Obj["Success"].ToString();
  1375. if (Success.ToUpper() == "FALSE")
  1376. {
  1377. msg = MessAge;
  1378. }
  1379. return msg;
  1380. }
  1381. //接口api解析
  1382. public static string HttpPost(string url, string body)
  1383. {
  1384. try
  1385. {
  1386. Encoding encoding = Encoding.UTF8;
  1387. HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
  1388. request.Method = "POST";
  1389. request.Accept = "application/json, text/javascript, */*"; //"text/html, application/xhtml+xml, */*";
  1390. request.ContentType = "application/json; charset=utf-8";
  1391. byte[] buffer = encoding.GetBytes(body);
  1392. request.ContentLength = buffer.Length;
  1393. request.GetRequestStream().Write(buffer, 0, buffer.Length);
  1394. HttpWebResponse response = (HttpWebResponse)request.GetResponse();
  1395. using (StreamReader reader = new StreamReader(response.GetResponseStream(), encoding))
  1396. {
  1397. return reader.ReadToEnd();
  1398. }
  1399. }
  1400. catch (WebException ex)
  1401. {
  1402. throw new Exception(ex.Message);
  1403. }
  1404. }
  1405. //销售出库
  1406. public string RevocationXSCK(string keyValue)
  1407. {
  1408. string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
  1409. string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
  1410. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  1411. string msg = "";
  1412. string sql = string.Empty;
  1413. JArray res = (JArray)JsonConvert.DeserializeObject(keyValue);
  1414. foreach (var item in res)
  1415. {
  1416. JObject jo = (JObject)item;
  1417. sql += $@" if NOT EXISTS(SELECT Id FROM ICSWareHouseLotInfoLog WHERE WorkPoint='{WorkPoint}' AND Identification=(select top 1 a.Identification from dbo.ICSWareHouseLotInfoLog a
  1418. where a.LotNo='{jo["LotNo"]}' and a.WorkPoint='{WorkPoint}' and isnull(EATTRIBUTE1,'')<>'1' order by a.MTIME desc) AND Identification='{jo["Identification"]}')
  1419. BEGIN
  1420. RAISERROR(',', 16, 1);
  1421. RETURN
  1422. END ;";
  1423. sql += string.Format(@"update ICSWareHouseLotInfo set Quantity=Quantity+'{0}',MTIME=getdate(),MUSER='{1}',MUSERName='{2}' where LotNo='{3}' and WorkPoint='{4}'", jo["Quantity"].ToString(), MUSER, MUSERNAME, jo["LotNo"].ToString(), WorkPoint);
  1424. sql += string.Format(@" update ICSSSD set SSDQuantity =SSDQuantity-'{0}' , MTIME=getdate(),MUSER='{1}',MUSERName='{2}' where SSDCode='{3}' and Sequence='{4}' and WorkPoint='{5}'", jo["Quantity"].ToString(), MUSER, MUSERNAME, jo["TransCode"].ToString(), jo["TransSequence"].ToString(), WorkPoint);
  1425. sql += string.Format(@"update ICSWareHouseLotInfoLog set EATTRIBUTE1 ='1' , EATTRIBUTE3=getdate(),EATTRIBUTE4='{0}',EATTRIBUTE5='{1}' where ID='{2}' and WorkPoint='{3}'", MUSER, MUSERNAME, jo["ID"].ToString(), WorkPoint);
  1426. }
  1427. try
  1428. {
  1429. if (SqlHelper.CmdExecuteNonQueryLi(sql) > 0)
  1430. {
  1431. }
  1432. }
  1433. catch (Exception ex)
  1434. {
  1435. msg = ex.Message;
  1436. }
  1437. return msg;
  1438. }
  1439. //销售出库(晶华销售出库)
  1440. public string RevocationXSCKJINH(string keyValue)
  1441. {
  1442. string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
  1443. string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
  1444. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  1445. string msg = "";
  1446. string sql = string.Empty;
  1447. JArray res = (JArray)JsonConvert.DeserializeObject(keyValue);
  1448. foreach (var item in res)
  1449. {
  1450. JObject jo = (JObject)item;
  1451. sql += $@" if NOT EXISTS(SELECT Id FROM ICSWareHouseLotInfoLog WHERE WorkPoint='{WorkPoint}' AND Identification=(select top 1 a.Identification from dbo.ICSWareHouseLotInfoLog a
  1452. where a.LotNo='{jo["LotNo"]}' and a.WorkPoint='{WorkPoint}' and isnull(EATTRIBUTE1,'')<>'1' order by a.MTIME desc) AND Identification='{jo["Identification"]}')
  1453. BEGIN
  1454. RAISERROR(',', 16, 1);
  1455. RETURN
  1456. END ;";
  1457. sql += string.Format(@"update ICSWareHouseLotInfo set Quantity=Quantity+'{0}',MTIME=getdate(),MUSER='{1}',MUSERName='{2}' where LotNo='{3}' and WorkPoint='{4}'", jo["Quantity"].ToString(), MUSER, MUSERNAME, jo["LotNo"].ToString(), WorkPoint);
  1458. sql += string.Format(@" update ICSSSD set SSDQuantity =SSDQuantity-'{0}' , MTIME=getdate(),MUSER='{1}',MUSERName='{2}' where SSDCode='{3}' and Sequence='{4}' and WorkPoint='{5}'", jo["Quantity"].ToString(), MUSER, MUSERNAME, jo["TransCode"].ToString(), jo["TransSequence"].ToString(), WorkPoint);
  1459. sql += string.Format(@"update ICSWareHouseLotInfoLog set EATTRIBUTE1 ='1' , EATTRIBUTE3=getdate(),EATTRIBUTE4='{0}',EATTRIBUTE5='{1}' where ID='{2}' and WorkPoint='{3}'", MUSER, MUSERNAME, jo["ID"].ToString(), WorkPoint);
  1460. }
  1461. try
  1462. {
  1463. if (SqlHelper.CmdExecuteNonQueryLi(sql) > 0)
  1464. {
  1465. }
  1466. }
  1467. catch (Exception ex)
  1468. {
  1469. msg = ex.Message;
  1470. }
  1471. return msg;
  1472. }
  1473. public string RevocationHZXSCK(string keyValue)
  1474. {
  1475. string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
  1476. string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
  1477. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  1478. string msg = "";
  1479. string sql = string.Empty;
  1480. JArray res = (JArray)JsonConvert.DeserializeObject(keyValue);
  1481. foreach (var item in res)
  1482. {
  1483. JObject jo = (JObject)item;
  1484. sql += $@" if NOT EXISTS(SELECT Id FROM ICSWareHouseLotInfoLog WHERE WorkPoint='{WorkPoint}' AND Identification=(select top 1 a.Identification from dbo.ICSWareHouseLotInfoLog a
  1485. where a.LotNo='{jo["LotNo"]}' and a.WorkPoint='{WorkPoint}' and isnull(EATTRIBUTE1,'')<>'1' order by a.MTIME desc) AND Identification='{jo["Identification"]}')
  1486. BEGIN
  1487. RAISERROR(',', 16, 1);
  1488. RETURN
  1489. END ;";
  1490. sql += string.Format(@"delete from ICSWareHouseLotInfo where LotNo='{0}' and WorkPoint='{1}' ", jo["LotNo"].ToString(), WorkPoint);
  1491. sql += string.Format(@"update ICSSSD set SSDQuantity =SSDQuantity-'{0}' where SSDCode='{1}' and Sequence='{2}' and WorkPoint='{3}' and Type='2'", jo["Quantity"].ToString(), jo["TransCode"].ToString(), jo["TransSequence"].ToString(), WorkPoint);
  1492. sql += string.Format(@"update ICSWareHouseLotInfoLog set EATTRIBUTE1 ='1' , EATTRIBUTE3=getdate(),EATTRIBUTE4='{0}',EATTRIBUTE5='{1}' where ID='{2}' and WorkPoint='{3}'", MUSER, MUSERNAME, jo["ID"].ToString(), WorkPoint);
  1493. }
  1494. try
  1495. {
  1496. if (SqlHelper.CmdExecuteNonQueryLi(sql) > 0)
  1497. {
  1498. }
  1499. }
  1500. catch (Exception ex)
  1501. {
  1502. msg = ex.Message;
  1503. }
  1504. return msg;
  1505. }
  1506. //采购入库撤销
  1507. public string RevocationSHDRK(string keyValue)
  1508. {
  1509. string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
  1510. string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
  1511. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  1512. string msg = "";
  1513. string sql = string.Empty;
  1514. JArray res = (JArray)JsonConvert.DeserializeObject(keyValue);
  1515. foreach (var item in res)
  1516. {
  1517. JObject jo = (JObject)item;
  1518. sql += $@" if NOT EXISTS(SELECT Id FROM ICSWareHouseLotInfoLog WHERE WorkPoint='{WorkPoint}' AND Identification=(select top 1 a.Identification from dbo.ICSWareHouseLotInfoLog a
  1519. where a.LotNo='{jo["LotNo"]}' and a.WorkPoint='{WorkPoint}' and isnull(EATTRIBUTE1,'')<>'1' order by a.MTIME desc) AND Identification='{jo["Identification"]}')
  1520. BEGIN
  1521. RAISERROR(',', 16, 1);
  1522. RETURN
  1523. END ;";
  1524. sql += string.Format(@"delete from ICSWareHouseLotInfo where LotNo='{0}' and WorkPoint='{1}' ", jo["LotNo"].ToString(), WorkPoint);
  1525. sql += string.Format(@"update ICSPurchaseReceive set RCVQuantity =RCVQuantity-'{0}' where RCVCode='{1}' and Sequence='{2}' and WorkPoint='{3}'", jo["Quantity"].ToString(), jo["TransCode"].ToString(), jo["TransSequence"].ToString(), WorkPoint);
  1526. sql += string.Format(@"update ICSWareHouseLotInfoLog set EATTRIBUTE1 ='1' , EATTRIBUTE3=getdate(),EATTRIBUTE4='{0}',EATTRIBUTE5='{1}' where ID='{2}' and WorkPoint='{3}'", MUSER, MUSERNAME, jo["ID"].ToString(), WorkPoint);
  1527. }
  1528. try
  1529. {
  1530. if (SqlHelper.CmdExecuteNonQueryLi(sql) > 0)
  1531. {
  1532. }
  1533. }
  1534. catch (Exception ex)
  1535. {
  1536. msg = ex.Message;
  1537. }
  1538. return msg;
  1539. }
  1540. //生产订单备料表
  1541. public string RevocationPickingJHBWLL(string keyValue)
  1542. {
  1543. string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
  1544. string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
  1545. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  1546. string msg = "";
  1547. string sql = string.Empty;
  1548. JArray res = (JArray)JsonConvert.DeserializeObject(keyValue);
  1549. foreach (var item in res)
  1550. {
  1551. JObject jo = (JObject)item;
  1552. sql += $@" if NOT EXISTS(SELECT Id FROM ICSWareHouseLotInfoLog WHERE WorkPoint='{WorkPoint}' AND Identification=(select top 1 a.Identification from dbo.ICSWareHouseLotInfoLog a
  1553. where a.LotNo='{jo["LotNo"]}' and a.WorkPoint='{WorkPoint}' and isnull(EATTRIBUTE1,'')<>'1' order by a.MTIME desc) AND Identification='{jo["Identification"]}')
  1554. BEGIN
  1555. RAISERROR(',', 16, 1);
  1556. RETURN
  1557. END ;";
  1558. sql += string.Format(@"update ICSWareHouseLotInfo set Quantity=Quantity+'{0}',MTIME=getdate(),MUSER='{1}',MUSERName='{2}' where LotNo='{3}' and WorkPoint='{4}'", jo["Quantity"].ToString(), MUSER, MUSERNAME, jo["LotNo"].ToString(), WorkPoint);
  1559. string checksql = @"select a.id from ICSMOPick a
  1560. INNER JOIN ICSMO b ON a.MODetailID=b.MODetailID AND a.WorkPoint=b.WorkPoint
  1561. where b.mocode='{0}' and a.WorkPoint='{1}' AND a.SupplyType='3' AND b.MOStatus<>'3' and a.EATTRIBUTE1<>'1' ";
  1562. checksql = string.Format(checksql, jo["TransCode"].ToString(), WorkPoint);
  1563. DataTable checkdt = SqlHelper.GetDataTableBySql(checksql);
  1564. if (checkdt.Rows.Count == 0 || checkdt == null)
  1565. {//不需要回写单据数量
  1566. }
  1567. else
  1568. {//需要回写单据子件已领数量
  1569. sql += string.Format(@"update a set IssueQuantity =IssueQuantity-'{0}' from ICSMOPick a left join ICSMO b on a.MODetailID=b.MODetailID and a.WorkPoint=b.WorkPoint
  1570. where b.MOCode='{1}' and b.Sequence+'~'+a.Sequence='{2}' and a.WorkPoint='{3}'", jo["Quantity"].ToString(), jo["TransCode"].ToString(), jo["TransSequence"].ToString(), WorkPoint);
  1571. }
  1572. sql += string.Format(@"update ICSWareHouseLotInfoLog set EATTRIBUTE1 ='1' , EATTRIBUTE3=getdate(),EATTRIBUTE4='{0}',EATTRIBUTE5='{1}' where ID='{2}' and WorkPoint='{3}'", MUSER, MUSERNAME, jo["ID"].ToString(), WorkPoint);
  1573. }
  1574. try
  1575. {
  1576. if (SqlHelper.CmdExecuteNonQueryLi(sql) > 0)
  1577. {
  1578. }
  1579. }
  1580. catch (Exception ex)
  1581. {
  1582. msg = ex.Message;
  1583. }
  1584. return msg;
  1585. }
  1586. //副产品入库
  1587. public string RevocationFCPRK(string keyValue)
  1588. {
  1589. string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
  1590. string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
  1591. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  1592. string msg = "";
  1593. string sql = string.Empty;
  1594. JArray res = (JArray)JsonConvert.DeserializeObject(keyValue);
  1595. foreach (var item in res)
  1596. {
  1597. JObject jo = (JObject)item;
  1598. sql += $@" if NOT EXISTS(SELECT Id FROM ICSWareHouseLotInfoLog WHERE WorkPoint='{WorkPoint}' AND Identification=(select top 1 a.Identification from dbo.ICSWareHouseLotInfoLog a
  1599. where a.LotNo='{jo["LotNo"]}' and a.WorkPoint='{WorkPoint}' and isnull(EATTRIBUTE1,'')<>'1' order by a.MTIME desc) AND Identification='{jo["Identification"]}')
  1600. BEGIN
  1601. RAISERROR(',', 16, 1);
  1602. RETURN
  1603. END ;";
  1604. sql += string.Format(@"delete from ICSWareHouseLotInfo where LotNo='{0}' and WorkPoint='{1}'", jo["LotNo"].ToString(), WorkPoint);
  1605. sql += string.Format(@"UPDATE d SET IssueQuantity=ISNULL(IssueQuantity,0)+'{2}'
  1606. FROM ICSInventoryLot a
  1607. INNER JOIN ICSInventoryLotDetail b ON a.LotNo=b.LotNo AND a.WorkPoint=b.WorkPoint
  1608. INNER JOIN ICSMO c ON b.TransCode=c.MOCode AND b.WorkPoint=c.WorkPoint
  1609. INNER JOIN ICSMOPick d ON c.MODetailID=d.MODetailID AND b.TransSequence=c.Sequence+'~'+d.Sequence AND b.WorkPoint=d.WorkPoint
  1610. WHERE a.LotNo='{0}' AND a.WorkPoint='{1}'", jo["LotNo"].ToString(), WorkPoint,jo["Quantity"].ToString() );
  1611. sql += string.Format(@"update ICSWareHouseLotInfoLog set EATTRIBUTE1 ='1' , EATTRIBUTE3=getdate(),EATTRIBUTE4='{0}',EATTRIBUTE5='{1}' where ID='{2}' and WorkPoint='{3}'", MUSER, MUSERNAME, jo["ID"].ToString(), WorkPoint);
  1612. }
  1613. try
  1614. {
  1615. if (SqlHelper.CmdExecuteNonQueryLi(sql) > 0)
  1616. {
  1617. }
  1618. }
  1619. catch (Exception ex)
  1620. {
  1621. msg = ex.Message;
  1622. }
  1623. return msg;
  1624. }
  1625. public string RevocationHP(string keyValue)
  1626. {
  1627. string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
  1628. string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
  1629. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  1630. string msg = "";
  1631. string sql = string.Empty;
  1632. JArray res = (JArray)JsonConvert.DeserializeObject(keyValue);
  1633. foreach (var item in res)
  1634. {
  1635. JObject jo = (JObject)item;
  1636. sql += $@" if NOT EXISTS(SELECT Id FROM ICSWareHouseLotInfoLog WHERE WorkPoint='{WorkPoint}' AND Identification=(select top 1 a.Identification from dbo.ICSWareHouseLotInfoLog a
  1637. where a.LotNo='{jo["LotNo"]}' and a.WorkPoint='{WorkPoint}' and isnull(EATTRIBUTE1,'')<>'1' order by a.MTIME desc) AND Identification='{jo["Identification"]}')
  1638. BEGIN
  1639. RAISERROR(',', 16, 1);
  1640. RETURN
  1641. END ;";
  1642. sql += string.Format(@"UPDATE a set a.Quantity = b.Quantity
  1643. FROM ICSWareHouseLotInfo a
  1644. INNER JOIN ICSWareHouseLotInfoLog b ON a.LotNo = b.LotNo and a.WorkPoint=b.WorkPoint
  1645. WHERE b.BusinessCode = '33' AND b.Identification = '{0}' and a.WorkPoint='{1}' ", jo["Identification"].ToString(), WorkPoint);
  1646. sql += string.Format(@"update ICSWareHouseLotInfoLog set EATTRIBUTE1 ='1' , EATTRIBUTE3=getdate(),EATTRIBUTE4='{0}',EATTRIBUTE5='{1}' where Identification='{2}' and WorkPoint='{3}'", MUSER, MUSERNAME, jo["Identification"].ToString(), WorkPoint);
  1647. }
  1648. try
  1649. {
  1650. if (SqlHelper.CmdExecuteNonQueryLi(sql) > 0)
  1651. {
  1652. }
  1653. }
  1654. catch (Exception ex)
  1655. {
  1656. msg = ex.Message;
  1657. }
  1658. return msg;
  1659. }
  1660. //移库
  1661. public string RevocationYK(string keyValue)
  1662. {
  1663. string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
  1664. string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
  1665. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  1666. string msg = "";
  1667. string sql = string.Empty;
  1668. JArray res = (JArray)JsonConvert.DeserializeObject(keyValue);
  1669. foreach (var item in res)
  1670. {
  1671. JObject jo = (JObject)item;
  1672. sql += $@" if NOT EXISTS(SELECT Id FROM ICSWareHouseLotInfoLog WHERE WorkPoint='{WorkPoint}' AND Identification=(select top 1 a.Identification from dbo.ICSWareHouseLotInfoLog a
  1673. where a.LotNo='{jo["LotNo"]}' and a.WorkPoint='{WorkPoint}' and isnull(EATTRIBUTE1,'')<>'1' order by a.MTIME desc) AND Identification='{jo["Identification"]}')
  1674. BEGIN
  1675. RAISERROR(',', 16, 1);
  1676. RETURN
  1677. END ;";
  1678. sql += string.Format(@"update ICSWareHouseLotInfo set MTIME=getdate(),MUSER='{0}',MUSERName='{1}',WarehouseCode='{4}',LocationCode='{5}' where LotNo='{2}' and WorkPoint='{3}'", MUSER, MUSERNAME, jo["LotNo"].ToString(), WorkPoint, jo["FromWarehouseCode"].ToString(), jo["FromLocationCode"].ToString());
  1679. sql += string.Format(@"update ICSWareHouseLotInfoLog set EATTRIBUTE1 ='1' , EATTRIBUTE3=getdate(),EATTRIBUTE4='{0}',EATTRIBUTE5='{1}' where ID='{2}' and WorkPoint='{3}'", MUSER, MUSERNAME, jo["ID"].ToString(), WorkPoint);
  1680. }
  1681. try
  1682. {
  1683. if (SqlHelper.CmdExecuteNonQueryLi(sql) > 0)
  1684. {
  1685. }
  1686. }
  1687. catch (Exception ex)
  1688. {
  1689. msg = ex.Message;
  1690. }
  1691. return msg;
  1692. }
  1693. //其他入库红字
  1694. public string RevocationQTRKHZ(string keyValue)
  1695. {
  1696. string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
  1697. string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
  1698. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  1699. string msg = "";
  1700. string sql = string.Empty;
  1701. JArray res = (JArray)JsonConvert.DeserializeObject(keyValue);
  1702. foreach (var item in res)
  1703. {
  1704. JObject jo = (JObject)item;
  1705. sql += $@" if NOT EXISTS(SELECT Id FROM ICSWareHouseLotInfoLog WHERE WorkPoint='{WorkPoint}' AND Identification=(select top 1 a.Identification from dbo.ICSWareHouseLotInfoLog a
  1706. where a.LotNo='{jo["LotNo"]}' and a.WorkPoint='{WorkPoint}' and isnull(EATTRIBUTE1,'')<>'1' order by a.MTIME desc) AND Identification='{jo["Identification"]}')
  1707. BEGIN
  1708. RAISERROR(',', 16, 1);
  1709. RETURN
  1710. END ;";
  1711. sql += string.Format(@"update ICSWareHouseLotInfo set Quantity=Quantity+'{0}',MTIME=getdate(),MUSER='{1}',MUSERName='{2}' where LotNo='{3}' and WorkPoint='{4}'", jo["Quantity"].ToString(), MUSER, MUSERNAME, jo["LotNo"].ToString(), WorkPoint);
  1712. sql += string.Format(@"update ICSOtherIn set InQuantity =InQuantity-'{0}' where RCVCode='{1}' and Sequence='{2}' and WorkPoint='{3}' and Type='2' ", jo["Quantity"].ToString(), jo["TransCode"].ToString(), jo["TransSequence"].ToString(), WorkPoint);
  1713. sql += string.Format(@"update ICSWareHouseLotInfoLog set EATTRIBUTE1 ='1' , EATTRIBUTE3=getdate(),EATTRIBUTE4='{0}',EATTRIBUTE5='{1}' where ID='{2}' and WorkPoint='{3}'", MUSER, MUSERNAME, jo["ID"].ToString(), WorkPoint);
  1714. }
  1715. try
  1716. {
  1717. if (SqlHelper.CmdExecuteNonQueryLi(sql) > 0)
  1718. {
  1719. }
  1720. }
  1721. catch (Exception ex)
  1722. {
  1723. msg = ex.Message;
  1724. }
  1725. return msg;
  1726. }
  1727. }
  1728. }