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.

570 lines
30 KiB

  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. namespace NFine.Application.WMS
  8. {
  9. public class RevokeBusinessApp : RepositoryFactory<ICSVendor>
  10. {
  11. //采购入库撤销
  12. public string RevocationPurchase(string keyValue)
  13. {
  14. string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
  15. string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
  16. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  17. string msg = "";
  18. string sql = string.Empty;
  19. JArray res = (JArray)JsonConvert.DeserializeObject(keyValue);
  20. foreach (var item in res)
  21. {
  22. JObject jo = (JObject)item;
  23. sql += string.Format(@"delete from ICSWareHouseLotInfo where LotNo='{0}' and WorkPoint='{1}' ", jo["LotNo"].ToString(), WorkPoint);
  24. 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);
  25. 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);
  26. }
  27. try
  28. {
  29. if (SqlHelper.CmdExecuteNonQueryLi(sql) > 0)
  30. {
  31. }
  32. }
  33. catch (Exception ex)
  34. {
  35. msg = ex.Message;
  36. }
  37. return msg;
  38. }
  39. //采购入库-采购到货单撤销
  40. public string RevocationDeliveryNotice(string keyValue)
  41. {
  42. string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
  43. string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
  44. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  45. string msg = "";
  46. string sql = string.Empty;
  47. JArray res = (JArray)JsonConvert.DeserializeObject(keyValue);
  48. foreach (var item in res)
  49. {
  50. JObject jo = (JObject)item;
  51. sql += string.Format(@"delete from ICSWareHouseLotInfo where LotNo='{0}' and WorkPoint='{1}' ", jo["LotNo"].ToString(), WorkPoint);
  52. 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);
  53. 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);
  54. }
  55. try
  56. {
  57. if (SqlHelper.CmdExecuteNonQueryLi(sql) > 0)
  58. {
  59. }
  60. }
  61. catch (Exception ex)
  62. {
  63. msg = ex.Message;
  64. }
  65. return msg;
  66. }
  67. //生产订单备料表
  68. public string RevocationPicking(string keyValue)
  69. {
  70. string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
  71. string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
  72. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  73. string msg = "";
  74. string sql = string.Empty;
  75. JArray res = (JArray)JsonConvert.DeserializeObject(keyValue);
  76. foreach (var item in res)
  77. {
  78. JObject jo = (JObject)item;
  79. 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);
  80. 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
  81. where b.MOCode='{1}' and b.Sequence+'~'+a.Sequence='{2}' and a.WorkPoint='{3}'", jo["Quantity"].ToString(), jo["TransCode"].ToString(), jo["TransSequence"].ToString(), WorkPoint);
  82. 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);
  83. }
  84. try
  85. {
  86. if (SqlHelper.CmdExecuteNonQueryLi(sql) > 0)
  87. {
  88. }
  89. }
  90. catch (Exception ex)
  91. {
  92. msg = ex.Message;
  93. }
  94. return msg;
  95. }
  96. //领料申请单
  97. public string RevocationMOApply(string keyValue)
  98. {
  99. string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
  100. string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
  101. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  102. string msg = "";
  103. string sql = string.Empty;
  104. JArray res = (JArray)JsonConvert.DeserializeObject(keyValue);
  105. foreach (var item in res)
  106. {
  107. JObject jo = (JObject)item;
  108. 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);
  109. 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);
  110. 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);
  111. }
  112. try
  113. {
  114. if (SqlHelper.CmdExecuteNonQueryLi(sql) > 0)
  115. {
  116. }
  117. }
  118. catch (Exception ex)
  119. {
  120. msg = ex.Message;
  121. }
  122. return msg;
  123. }
  124. //材料出库
  125. public string RevocationMOIssue(string keyValue)
  126. {
  127. string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
  128. string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
  129. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  130. string msg = "";
  131. string sql = string.Empty;
  132. JArray res = (JArray)JsonConvert.DeserializeObject(keyValue);
  133. foreach (var item in res)
  134. {
  135. JObject jo = (JObject)item;
  136. 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);
  137. 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);
  138. 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);
  139. }
  140. try
  141. {
  142. if (SqlHelper.CmdExecuteNonQueryLi(sql) > 0)
  143. {
  144. }
  145. }
  146. catch (Exception ex)
  147. {
  148. msg = ex.Message;
  149. }
  150. return msg;
  151. }
  152. //产成品入库-生产订单
  153. public string RevocationFinished(string keyValue)
  154. {
  155. string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
  156. string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
  157. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  158. string msg = "";
  159. string sql = string.Empty;
  160. JArray res = (JArray)JsonConvert.DeserializeObject(keyValue);
  161. foreach (var item in res)
  162. {
  163. JObject jo = (JObject)item;
  164. sql += string.Format(@"delete from ICSWareHouseLotInfo where LotNo='{0}' and WorkPoint='{1}'", jo["LotNo"].ToString(), WorkPoint);
  165. 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);
  166. 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);
  167. }
  168. try
  169. {
  170. if (SqlHelper.CmdExecuteNonQueryLi(sql) > 0)
  171. {
  172. }
  173. }
  174. catch (Exception ex)
  175. {
  176. msg = ex.Message;
  177. }
  178. return msg;
  179. }
  180. //产成品入库-产成品入库单
  181. public string RevocationManufactureReceive(string keyValue)
  182. {
  183. string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
  184. string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
  185. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  186. string msg = "";
  187. string sql = string.Empty;
  188. JArray res = (JArray)JsonConvert.DeserializeObject(keyValue);
  189. foreach (var item in res)
  190. {
  191. JObject jo = (JObject)item;
  192. sql += string.Format(@"delete from ICSWareHouseLotInfo where LotNo='{0}' and WorkPoint='{1}'", jo["LotNo"].ToString(), WorkPoint);
  193. 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);
  194. 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);
  195. }
  196. try
  197. {
  198. if (SqlHelper.CmdExecuteNonQueryLi(sql) > 0)
  199. {
  200. }
  201. }
  202. catch (Exception ex)
  203. {
  204. msg = ex.Message;
  205. }
  206. return msg;
  207. }
  208. //一步调拨
  209. public string RevocationICSTransfer(string keyValue)
  210. {
  211. string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
  212. string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
  213. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  214. string msg = "";
  215. string sql = string.Empty;
  216. JArray res = (JArray)JsonConvert.DeserializeObject(keyValue);
  217. foreach (var item in res)
  218. {
  219. JObject jo = (JObject)item;
  220. 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());
  221. 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);
  222. 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);
  223. }
  224. try
  225. {
  226. if (SqlHelper.CmdExecuteNonQueryLi(sql) > 0)
  227. {
  228. }
  229. }
  230. catch (Exception ex)
  231. {
  232. msg = ex.Message;
  233. }
  234. return msg;
  235. }
  236. //销售出库
  237. public string RevocationMarket(string keyValue)
  238. {
  239. string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
  240. string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
  241. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  242. string msg = "";
  243. string sql = string.Empty;
  244. JArray res = (JArray)JsonConvert.DeserializeObject(keyValue);
  245. foreach (var item in res)
  246. {
  247. JObject jo = (JObject)item;
  248. 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);
  249. 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);
  250. 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);
  251. }
  252. try
  253. {
  254. if (SqlHelper.CmdExecuteNonQueryLi(sql) > 0)
  255. {
  256. }
  257. }
  258. catch (Exception ex)
  259. {
  260. msg = ex.Message;
  261. }
  262. return msg;
  263. }
  264. //生产退料-生产退料单
  265. public string RevocationProduceStripping(string keyValue)
  266. {
  267. string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
  268. string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
  269. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  270. string msg = "";
  271. string sql = string.Empty;
  272. JArray res = (JArray)JsonConvert.DeserializeObject(keyValue);
  273. foreach (var item in res)
  274. {
  275. JObject jo = (JObject)item;
  276. string sqlseach = @"select Type from dbo.ICSInventoryLot where LotNo='"+ jo["LotNo"].ToString() + "'";
  277. object LotNoType= SqlHelper.ExecuteScalar(sqlseach);
  278. if (LotNoType.ToString()== "1")
  279. {
  280. //新条码退
  281. sql += string.Format(@"delete from ICSWareHouseLotInfo where LotNo='{0}' and WorkPoint='{1}'", jo["LotNo"].ToString(), WorkPoint);
  282. 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);
  283. 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);
  284. sql += string.Format(@" UPDATE e SET IssueQuantity=ISNULL(IssueQuantity,0)+'{2}'
  285. FROM ICSInventoryLot a
  286. INNER JOIN ICSInventoryLotDetail b ON a.LotNo=b.LotNo AND a.WorkPoint=b.WorkPoint
  287. INNER JOIN ICSMOApplyNegDetail c ON b.TransCode=c.ApplyNegCode AND b.TransSequence=c.Sequence AND b.WorkPoint=c.WorkPoint
  288. INNER JOIN ICSMOApplyNeg d ON c.ApplyNegCode=d.ApplyNegCode AND c.WorkPoint=d.WorkPoint
  289. INNER JOIN ICSMOPick e ON c.SourceDetailID=e.PickID AND c.WorkPoint=e.WorkPoint
  290. WHERE a.LotNo='{0}' AND a.WorkPoint='{1}' AND d.Type='1'", jo["LotNo"].ToString(), WorkPoint, jo["Quantity"].ToString());
  291. }
  292. else
  293. {
  294. 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);
  295. // 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);
  296. 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);
  297. sql += string.Format(@"UPDATE c SET IssueQuantity=ISNULL(IssueQuantity,0)+'{2}'
  298. FROM ICSWareHouseLotInfoLog a
  299. INNER JOIN ICSMO b ON a.TransCode=b.MOCode AND a.WorkPoint=b.WorkPoint
  300. INNER JOIN ICSMOPick c ON b.MODetailID = c.MODetailID AND b.WorkPoint = c.WorkPoint AND a.TransSequence = b.Sequence + '~' + c.Sequence
  301. WHERE a.LotNo='{0}' AND a.WorkPoint='{1}' AND a.ID='{3}'", jo["LotNo"].ToString(), WorkPoint, jo["Quantity"].ToString(), jo["ID"].ToString());
  302. }
  303. }
  304. try
  305. {
  306. if (SqlHelper.CmdExecuteNonQueryLi(sql) > 0)
  307. {
  308. }
  309. }
  310. catch (Exception ex)
  311. {
  312. msg = ex.Message;
  313. }
  314. return msg;
  315. }
  316. //生产退料-生产退料单-领料申请单
  317. public string RevocationProduceStrippingLL(string keyValue)
  318. {
  319. string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
  320. string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
  321. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  322. string msg = "";
  323. string sql = string.Empty;
  324. JArray res = (JArray)JsonConvert.DeserializeObject(keyValue);
  325. foreach (var item in res)
  326. {
  327. JObject jo = (JObject)item;
  328. string sqlseach = @"select Type from dbo.ICSInventoryLot where LotNo='" + jo["LotNo"].ToString() + "'";
  329. object LotNoType = SqlHelper.ExecuteScalar(sqlseach);
  330. if (LotNoType.ToString() == "1")
  331. {
  332. //新条码退
  333. sql += string.Format(@"delete from ICSWareHouseLotInfo where LotNo='{0}' and WorkPoint='{1}'", jo["LotNo"].ToString(), WorkPoint);
  334. 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);
  335. 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);
  336. sql += string.Format(@" UPDATE e SET IssueQuantity=ISNULL(IssueQuantity,0)+'{2}'
  337. FROM ICSInventoryLot a
  338. INNER JOIN ICSInventoryLotDetail b ON a.LotNo=b.LotNo AND a.WorkPoint=b.WorkPoint
  339. INNER JOIN ICSMOApplyNegDetail c ON b.TransCode=c.ApplyNegCode AND b.TransSequence=c.Sequence AND b.WorkPoint=c.WorkPoint
  340. INNER JOIN ICSMOApplyNeg d ON c.ApplyNegCode=d.ApplyNegCode AND c.WorkPoint=d.WorkPoint
  341. INNER JOIN ICSMOApply e ON c.SourceDetailID=e.ApplyDetailID AND c.WorkPoint=e.WorkPoint
  342. WHERE a.LotNo='{0}' AND a.WorkPoint='{1}' AND d.Type='2'", jo["LotNo"].ToString(), WorkPoint, jo["Quantity"].ToString());
  343. }
  344. else
  345. {
  346. 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);
  347. // 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);
  348. 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);
  349. sql += string.Format(@"UPDATE c SET IssueQuantity=ISNULL(IssueQuantity,0)+'{2}'
  350. FROM ICSWareHouseLotInfoLog a
  351. INNER JOIN ICSMOApply c ON a.TransCode=c.ApplyCode AND a.TransSequence=c.Sequence AND a.WorkPoint=c.WorkPoint
  352. WHERE a.LotNo='{0}' AND a.WorkPoint='{1}' AND a.ID='{3}'", jo["LotNo"].ToString(), WorkPoint, jo["Quantity"].ToString(), jo["ID"].ToString());
  353. }
  354. }
  355. try
  356. {
  357. if (SqlHelper.CmdExecuteNonQueryLi(sql) > 0)
  358. {
  359. }
  360. }
  361. catch (Exception ex)
  362. {
  363. msg = ex.Message;
  364. }
  365. return msg;
  366. }
  367. //生产退料-生产退料单-材料出库单
  368. public string RevocationProduceStrippingCLCK(string keyValue)
  369. {
  370. string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
  371. string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
  372. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  373. string msg = "";
  374. string sql = string.Empty;
  375. JArray res = (JArray)JsonConvert.DeserializeObject(keyValue);
  376. foreach (var item in res)
  377. {
  378. JObject jo = (JObject)item;
  379. string sqlseach = @"select Type from dbo.ICSInventoryLot where LotNo='" + jo["LotNo"].ToString() + "'";
  380. object LotNoType = SqlHelper.ExecuteScalar(sqlseach);
  381. if (LotNoType.ToString() == "1")
  382. {
  383. //新条码退
  384. sql += string.Format(@"delete from ICSWareHouseLotInfo where LotNo='{0}' and WorkPoint='{1}'", jo["LotNo"].ToString(), WorkPoint);
  385. 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);
  386. 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);
  387. sql += string.Format(@" UPDATE e SET IssueQuantity=ISNULL(IssueQuantity,0)+'{2}'
  388. FROM ICSInventoryLot a
  389. INNER JOIN ICSInventoryLotDetail b ON a.LotNo=b.LotNo AND a.WorkPoint=b.WorkPoint
  390. INNER JOIN ICSMOApplyNegDetail c ON b.TransCode=c.ApplyNegCode AND b.TransSequence=c.Sequence AND b.WorkPoint=c.WorkPoint
  391. INNER JOIN ICSMOApplyNeg d ON c.ApplyNegCode=d.ApplyNegCode AND c.WorkPoint=d.WorkPoint
  392. INNER JOIN ICSMOIssue e ON c.SourceDetailID=e.IssueDetailID AND c.WorkPoint=e.WorkPoint
  393. WHERE a.LotNo='{0}' AND a.WorkPoint='{1}' AND d.Type='3'", jo["LotNo"].ToString(), WorkPoint, jo["Quantity"].ToString());
  394. }
  395. else
  396. {
  397. 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);
  398. // 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);
  399. 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);
  400. sql += string.Format(@"UPDATE c SET IssueQuantity=ISNULL(IssueQuantity,0)+'{2}'
  401. FROM ICSWareHouseLotInfoLog a
  402. INNER JOIN ICSMOIssue c ON a.TransCode=c.IssueCode AND a.TransSequence=c.Sequence AND a.WorkPoint=c.WorkPoint
  403. WHERE a.LotNo='{0}' AND a.WorkPoint='{1}' AND a.ID='{3}'", jo["LotNo"].ToString(), WorkPoint, jo["Quantity"].ToString(), jo["ID"].ToString());
  404. }
  405. }
  406. try
  407. {
  408. if (SqlHelper.CmdExecuteNonQueryLi(sql) > 0)
  409. {
  410. }
  411. }
  412. catch (Exception ex)
  413. {
  414. msg = ex.Message;
  415. }
  416. return msg;
  417. }
  418. //其他出库(杂发)
  419. public string RevocationOtheOutboundr(string keyValue)
  420. {
  421. string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
  422. string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
  423. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  424. string msg = "";
  425. string sql = string.Empty;
  426. JArray res = (JArray)JsonConvert.DeserializeObject(keyValue);
  427. foreach (var item in res)
  428. {
  429. JObject jo = (JObject)item;
  430. 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);
  431. 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);
  432. 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);
  433. }
  434. try
  435. {
  436. if (SqlHelper.CmdExecuteNonQueryLi(sql) > 0)
  437. {
  438. }
  439. }
  440. catch (Exception ex)
  441. {
  442. msg = ex.Message;
  443. }
  444. return msg;
  445. }
  446. //其他入库(杂收)
  447. public string RevocationOtheWarehousing(string keyValue)
  448. {
  449. string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
  450. string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
  451. string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  452. string msg = "";
  453. string sql = string.Empty;
  454. JArray res = (JArray)JsonConvert.DeserializeObject(keyValue);
  455. foreach (var item in res)
  456. {
  457. JObject jo = (JObject)item;
  458. sql += string.Format(@"delete from ICSWareHouseLotInfo where LotNo='{0}' and WorkPoint='{1}'", jo["LotNo"].ToString(), WorkPoint);
  459. sql += string.Format(@" update ICSOtherIn set InQuantity =InQuantity-'{0}' where InCode='{1}' and Sequence='{2}' and WorkPoint='{3}' and Type='1' ", jo["Quantity"].ToString(), jo["TransCode"].ToString(), jo["TransSequence"].ToString(), WorkPoint);
  460. 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);
  461. }
  462. try
  463. {
  464. if (SqlHelper.CmdExecuteNonQueryLi(sql) > 0)
  465. {
  466. }
  467. }
  468. catch (Exception ex)
  469. {
  470. msg = ex.Message;
  471. }
  472. return msg;
  473. }
  474. }
  475. }