UpdateBarCode.cs 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. using UFSoft.UBF.Business;
  7. namespace UFIDA.U9.Cust.Kusi.CJJ.Plugin.BE.TransferIn
  8. {
  9. public class UpdateBarCode : UFSoft.UBF.Eventing.IEventSubscriber
  10. {
  11. public void Notify(params object[] args)
  12. {
  13. #region 从事件参数中取得当前业务实体
  14. if (args == null || args.Length == 0 || !(args[0] is UFSoft.UBF.Business.EntityEvent))
  15. return;
  16. BusinessEntity.EntityKey key = ((UFSoft.UBF.Business.EntityEvent)args[0]).EntityKey;
  17. if (key == null)
  18. return;
  19. UFIDA.U9.InvDoc.TransferIn.TransferIn holder = key.GetEntity() as UFIDA.U9.InvDoc.TransferIn.TransferIn;
  20. if (holder == null)
  21. return;
  22. #endregion
  23. //弃审时更新条码库位存储信息
  24. if (holder.Status == UFIDA.U9.InvDoc.TransferIn.TransInStatus.Opening
  25. && holder.OriginalData != null
  26. && holder.OriginalData.Status == UFIDA.U9.InvDoc.TransferIn.TransInStatus.Approved
  27. )
  28. {
  29. foreach (var line in holder.TransInLines)
  30. {
  31. using (ISession session = Session.Open())
  32. {
  33. UFIDA.U9.BC.BaseData.BarCodeUsed.EntityList tmp = UFIDA.U9.BC.BaseData.BarCodeUsed.Finder.FindAll("UseDocLine.EntityID=@ID and UseDocLine.EntityType=@EntityType and CurQty>0 order by CreatedOn desc"
  34. , new UFSoft.UBF.PL.OqlParam[]
  35. {
  36. new UFSoft.UBF.PL.OqlParam(line.ID),
  37. new UFSoft.UBF.PL.OqlParam("UFIDA.U9.InvDoc.TransferIn.TransInLine")
  38. });
  39. if (tmp != null && tmp.Count > 0)
  40. {
  41. List<UFIDA.U9.BC.BaseData.BarCodeUsed> list = BarCodeUpdater.Distinct(tmp);
  42. foreach (var barCodeUsed in list)
  43. {
  44. string barCodeTmp = barCodeUsed.BarCode;
  45. UFIDA.U9.BC.Common.DirectEnum directEnum = barCodeUsed.Direct;
  46. decimal qty = barCodeUsed.CurQty;
  47. barCodeUsed.Remove();
  48. session.Commit();
  49. var barCodeUsedTmp = UFIDA.U9.BC.BaseData.BarCodeUsed.Finder.Find(string.Format("BarCode='{0}' order by CreatedOn desc", barCodeTmp));
  50. string binid = "";
  51. string bincode = "";
  52. string binname = "";
  53. string whid = "";
  54. string whcode = "";
  55. string whname = "";
  56. if (barCodeUsedTmp != null)
  57. {
  58. binid = barCodeUsedTmp["Cust4Binid"].ToString();
  59. bincode = barCodeUsedTmp["Cust4Bincode"].ToString();
  60. binname = barCodeUsedTmp["Cust4Binname"].ToString();
  61. whid = barCodeUsedTmp["Cust4Whid"].ToString();
  62. whcode = barCodeUsedTmp["Cust4Whcode"].ToString();
  63. whname = barCodeUsedTmp["Cust4Whname"].ToString();
  64. }
  65. else
  66. {
  67. barCodeUsedTmp = barCodeUsed;
  68. }
  69. if (holder.TransferInType == CBO.SCM.Enums.TransferInType.TwoStepTransIn && barCodeUsed.IsUpdateWh)
  70. {
  71. if (directEnum == UFIDA.U9.BC.Common.DirectEnum.Rcv)
  72. {
  73. barCodeUsedTmp.BarCodeMaster.WhQty = barCodeUsedTmp.BarCodeMaster.WhQty - qty;
  74. if (barCodeUsedTmp.BarCodeMaster.WhQty < 0)
  75. {
  76. throw new Exception("不能弃审,弃审后条码现场量将小于0");
  77. }
  78. }
  79. }
  80. barCodeUsedTmp.BarCodeMaster.SetValue("Cust4Binid", binid);
  81. barCodeUsedTmp.BarCodeMaster.SetValue("Cust4Bincode", bincode);
  82. barCodeUsedTmp.BarCodeMaster.SetValue("Cust4Binname", binname);
  83. barCodeUsedTmp.BarCodeMaster.SetValue("Cust4Whcode", whcode);
  84. barCodeUsedTmp.BarCodeMaster.SetValue("Cust4Whname", whname);
  85. barCodeUsedTmp.BarCodeMaster.SetValue("Cust4Whid", whid);
  86. }
  87. }
  88. session.Commit();
  89. }
  90. }
  91. }
  92. ////提交前的保存时出入库单据审核控制条码仓
  93. //if (holder.Status == UFIDA.U9.InvDoc.TransferIn.TransInStatus.Opening
  94. // && holder.OriginalData != null
  95. // && holder.OriginalData.Status == UFIDA.U9.InvDoc.TransferIn.TransInStatus.Opening
  96. // )
  97. //{
  98. // foreach (var line in holder.TransInLines)
  99. // {
  100. // if (line.TransInWh != null)
  101. // {
  102. // if (line.TransInWh.DescFlexField.PrivateDescSeg1.ToUpper().Equals("TRUE") && !Base.Context.LoginUser.Contains("PDA"))
  103. // {
  104. // throw new Exception(string.Format("单号{0},{1}行的存储地点为条码管理,请扫码出货。", holder.DocNo, line.DocLineNo));
  105. // }
  106. // }
  107. // foreach (var subLine in line.TransInSubLines)
  108. // {
  109. // if (subLine.TransOutWh != null)
  110. // {
  111. // if (subLine.TransOutWh.DescFlexField.PrivateDescSeg1.ToUpper().Equals("TRUE") && !Base.Context.LoginUser.Contains("PDA"))
  112. // {
  113. // throw new Exception(string.Format("单号{0},{1}行的存储地点为条码管理,请扫码出货。", holder.DocNo, line.DocLineNo));
  114. // }
  115. // }
  116. // }
  117. // }
  118. //}
  119. }
  120. }
  121. }