123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using UFSoft.UBF.Business;
- namespace UFIDA.U9.Cust.Kusi.CJJ.Plugin.BE.TransferIn
- {
- public class UpdateBarCode : UFSoft.UBF.Eventing.IEventSubscriber
- {
- public void Notify(params object[] args)
- {
- #region 从事件参数中取得当前业务实体
- if (args == null || args.Length == 0 || !(args[0] is UFSoft.UBF.Business.EntityEvent))
- return;
- BusinessEntity.EntityKey key = ((UFSoft.UBF.Business.EntityEvent)args[0]).EntityKey;
- if (key == null)
- return;
- UFIDA.U9.InvDoc.TransferIn.TransferIn holder = key.GetEntity() as UFIDA.U9.InvDoc.TransferIn.TransferIn;
- if (holder == null)
- return;
- #endregion
- //弃审时更新条码库位存储信息
- if (holder.Status == UFIDA.U9.InvDoc.TransferIn.TransInStatus.Opening
- && holder.OriginalData != null
- && holder.OriginalData.Status == UFIDA.U9.InvDoc.TransferIn.TransInStatus.Approved
- )
- {
- foreach (var line in holder.TransInLines)
- {
- using (ISession session = Session.Open())
- {
- 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"
- , new UFSoft.UBF.PL.OqlParam[]
- {
- new UFSoft.UBF.PL.OqlParam(line.ID),
- new UFSoft.UBF.PL.OqlParam("UFIDA.U9.InvDoc.TransferIn.TransInLine")
- });
- if (tmp != null && tmp.Count > 0)
- {
- List<UFIDA.U9.BC.BaseData.BarCodeUsed> list = BarCodeUpdater.Distinct(tmp);
- foreach (var barCodeUsed in list)
- {
- string barCodeTmp = barCodeUsed.BarCode;
- UFIDA.U9.BC.Common.DirectEnum directEnum = barCodeUsed.Direct;
- decimal qty = barCodeUsed.CurQty;
- barCodeUsed.Remove();
- session.Commit();
- var barCodeUsedTmp = UFIDA.U9.BC.BaseData.BarCodeUsed.Finder.Find(string.Format("BarCode='{0}' order by CreatedOn desc", barCodeTmp));
- string binid = "";
- string bincode = "";
- string binname = "";
- string whid = "";
- string whcode = "";
- string whname = "";
- if (barCodeUsedTmp != null)
- {
- binid = barCodeUsedTmp["Cust4Binid"].ToString();
- bincode = barCodeUsedTmp["Cust4Bincode"].ToString();
- binname = barCodeUsedTmp["Cust4Binname"].ToString();
- whid = barCodeUsedTmp["Cust4Whid"].ToString();
- whcode = barCodeUsedTmp["Cust4Whcode"].ToString();
- whname = barCodeUsedTmp["Cust4Whname"].ToString();
- }
- else
- {
- barCodeUsedTmp = barCodeUsed;
- }
- if (holder.TransferInType == CBO.SCM.Enums.TransferInType.TwoStepTransIn && barCodeUsed.IsUpdateWh)
- {
- if (directEnum == UFIDA.U9.BC.Common.DirectEnum.Rcv)
- {
- barCodeUsedTmp.BarCodeMaster.WhQty = barCodeUsedTmp.BarCodeMaster.WhQty - qty;
- if (barCodeUsedTmp.BarCodeMaster.WhQty < 0)
- {
- throw new Exception("不能弃审,弃审后条码现场量将小于0");
- }
- }
- }
- barCodeUsedTmp.BarCodeMaster.SetValue("Cust4Binid", binid);
- barCodeUsedTmp.BarCodeMaster.SetValue("Cust4Bincode", bincode);
- barCodeUsedTmp.BarCodeMaster.SetValue("Cust4Binname", binname);
- barCodeUsedTmp.BarCodeMaster.SetValue("Cust4Whcode", whcode);
- barCodeUsedTmp.BarCodeMaster.SetValue("Cust4Whname", whname);
- barCodeUsedTmp.BarCodeMaster.SetValue("Cust4Whid", whid);
- }
- }
- session.Commit();
- }
- }
- }
- ////提交前的保存时出入库单据审核控制条码仓
- //if (holder.Status == UFIDA.U9.InvDoc.TransferIn.TransInStatus.Opening
- // && holder.OriginalData != null
- // && holder.OriginalData.Status == UFIDA.U9.InvDoc.TransferIn.TransInStatus.Opening
- // )
- //{
- // foreach (var line in holder.TransInLines)
- // {
-
- // if (line.TransInWh != null)
- // {
- // if (line.TransInWh.DescFlexField.PrivateDescSeg1.ToUpper().Equals("TRUE") && !Base.Context.LoginUser.Contains("PDA"))
- // {
- // throw new Exception(string.Format("单号{0},{1}行的存储地点为条码管理,请扫码出货。", holder.DocNo, line.DocLineNo));
- // }
- // }
- // foreach (var subLine in line.TransInSubLines)
- // {
- // if (subLine.TransOutWh != null)
- // {
- // if (subLine.TransOutWh.DescFlexField.PrivateDescSeg1.ToUpper().Equals("TRUE") && !Base.Context.LoginUser.Contains("PDA"))
- // {
- // throw new Exception(string.Format("单号{0},{1}行的存储地点为条码管理,请扫码出货。", holder.DocNo, line.DocLineNo));
- // }
- // }
- // }
- // }
- //}
- }
- }
- }
|