Beispiel #1
0
        public void AntiConfirmIpDetail(IList<int> ipDetailIdList)
        {
            if (ipDetailIdList == null && ipDetailIdList.Count == 0)
            {
                throw new BusinessException("发货确认明细不能为空。");
            }
            if (ipDetailIdList.Count > 2000)
            {
                throw new BusinessException("发货确认明细不能超过2000行。");
            }
            StringBuilder selectIpDetHql = null;
            StringBuilder selectIpMstrHql = null;
            StringBuilder selectIpConfirmHql = null;
            IList<object> selectIpDetParam = new List<object>();
            IList<object> selectIpMstrParam = new List<object>();
            IList<object> selectIpConfirmParam = new List<object>();

            foreach (int id in ipDetailIdList)
            {
                if (selectIpDetHql == null)
                {
                    selectIpDetHql = new StringBuilder("from IpDetail where Id in (?");
                    selectIpConfirmHql = new StringBuilder("from IpDetailConfirm where IpDetailId in (?");
                }
                else
                {
                    selectIpDetHql.Append(",?");
                    selectIpConfirmHql.Append(",?");
                }
                selectIpDetParam.Add(id);
                selectIpConfirmParam.Add(id);
            }
            selectIpDetHql.Append(")");
            selectIpConfirmHql.Append(") and IsCancel = ?");
            selectIpConfirmParam.Add(false);

            IList<IpDetail> ipDetailList = this.genericMgr.FindAll<IpDetail>(selectIpDetHql.ToString(), selectIpDetParam.ToArray());
            IList<IpDetailConfirm> ipDetailConfirmList = this.genericMgr.FindAll<IpDetailConfirm>(selectIpConfirmHql.ToString(), selectIpConfirmParam.ToArray());

            foreach (string ipNo in ipDetailList.Select(id => id.IpNo).Distinct())
            {
                if (selectIpMstrHql == null)
                {
                    selectIpMstrHql = new StringBuilder("from IpMaster where IpNo in (?");
                }
                else
                {
                    selectIpMstrHql.Append(",?");
                }
                selectIpMstrParam.Add(ipNo);
            }
            selectIpMstrHql.Append(")");

            IList<IpMaster> ipMasterList = this.genericMgr.FindAll<IpMaster>(selectIpMstrHql.ToString(), selectIpMstrParam.ToArray());

            DateTime dateTimeNow = DateTime.Now;
            User user = SecurityContextHolder.Get();
            foreach (IpDetail ipDetail in ipDetailList)
            {
                if (!ipDetail.IsIncludeTax)  //ASN确认发货
                {
                    throw new BusinessException("ASN{0}行号{1}没有确认发货。", ipDetail.IpNo, ipDetail.Sequence.ToString());
                }

                IpMaster ipMaster = ipMasterList.Where(im => im.IpNo == ipDetail.IpNo).Single();
                if (!string.IsNullOrEmpty(ipMaster.ExternalIpNo)  //取消ASN确认传给SAP的移动类型
                   || ipMaster.IsCheckPartyToAuthority)   //ASN确认发货创建DN
                {
                    IList<IpDetailConfirm> matchedipDetailConfirmList = ipDetailConfirmList.Where(idc => idc.IpDetailId == ipDetail.Id).ToList();
                    if (matchedipDetailConfirmList.Count() == 0)
                    {
                        throw new BusinessException("ASN{0}行号{1}没有找到发货确认记录。", ipDetail.IpNo, ipDetail.Sequence.ToString());
                    }
                    else if (matchedipDetailConfirmList.Count() > 1)
                    {
                        throw new BusinessException("ASN{0}行号{1}找到多条发货确认记录。", ipDetail.IpNo, ipDetail.Sequence.ToString());
                    }

                    IpDetailConfirm matchedIpDetailConfirm = matchedipDetailConfirmList.Single();

                    CancelIpDetailConfirm cancelIpDetailConfirm = new CancelIpDetailConfirm();
                    cancelIpDetailConfirm.IpDetailConfirmId = matchedIpDetailConfirm.Id;
                    cancelIpDetailConfirm.OrderNo = matchedIpDetailConfirm.OrderNo;
                    cancelIpDetailConfirm.OrderType = matchedIpDetailConfirm.OrderType;
                    cancelIpDetailConfirm.OrderSubType = matchedIpDetailConfirm.OrderSubType;
                    cancelIpDetailConfirm.OrderDetailId = matchedIpDetailConfirm.OrderDetailId;
                    cancelIpDetailConfirm.IpNo = matchedIpDetailConfirm.IpNo;
                    cancelIpDetailConfirm.IpDetailId = matchedIpDetailConfirm.IpDetailId;
                    cancelIpDetailConfirm.IpDetailSequence = matchedIpDetailConfirm.IpDetailSequence;
                    cancelIpDetailConfirm.Item = matchedIpDetailConfirm.Item;
                    cancelIpDetailConfirm.ItemDescription = matchedIpDetailConfirm.ItemDescription;
                    cancelIpDetailConfirm.Uom = matchedIpDetailConfirm.Uom;
                    cancelIpDetailConfirm.BaseUom = matchedIpDetailConfirm.BaseUom;
                    cancelIpDetailConfirm.UnitQty = matchedIpDetailConfirm.UnitQty;
                    cancelIpDetailConfirm.Qty = matchedIpDetailConfirm.Qty;
                    cancelIpDetailConfirm.PartyFrom = matchedIpDetailConfirm.PartyFrom;
                    cancelIpDetailConfirm.PartyTo = matchedIpDetailConfirm.PartyTo;
                    cancelIpDetailConfirm.LocationFrom = matchedIpDetailConfirm.LocationFrom;
                    cancelIpDetailConfirm.LocationTo = matchedIpDetailConfirm.LocationTo;
                    cancelIpDetailConfirm.ShipPlant = matchedIpDetailConfirm.ShipPlant;
                    cancelIpDetailConfirm.ShipLocation = matchedIpDetailConfirm.ShipLocation;
                    cancelIpDetailConfirm.IsCreateDN = matchedIpDetailConfirm.IsCreateDN;
                    cancelIpDetailConfirm.MoveType = ipMaster.ExternalIpNo;
                    cancelIpDetailConfirm.EBELN = matchedIpDetailConfirm.EBELN;
                    cancelIpDetailConfirm.EBELP = matchedIpDetailConfirm.EBELP;
                    cancelIpDetailConfirm.EffectiveDate = dateTimeNow;
                    cancelIpDetailConfirm.CreateUser = user.FullName;
                    cancelIpDetailConfirm.CreateDate = dateTimeNow;

                    this.genericMgr.Create(cancelIpDetailConfirm);

                    matchedIpDetailConfirm.IsCancel = true;
                    this.genericMgr.Update(matchedIpDetailConfirm);
                }

                ipDetail.IsIncludeTax = false;
                this.genericMgr.Update(ipDetail);
            }
        }
Beispiel #2
0
 private string GenerateCancelIpDetailConfirmNo(CancelIpDetailConfirm cancelIpDetailConfirm)
 {
     string numberSuffix = numberControlMgr.GetNextSequence
        (Entity.BusinessConstants.NUMBERCONTROL_SISAP + Entity.BusinessConstants.NUMBERCONTROL_CANCELIPDETCONFIRM);
     if (numberSuffix.Length > Entity.BusinessConstants.DATA_EXCHANGE_ORDER_NO_LENTH)
     {
         throw new Exception("numberSuffix.length > " + Entity.BusinessConstants.DATA_EXCHANGE_ORDER_NO_LENTH);
     }
     numberSuffix = numberSuffix.PadLeft(Entity.BusinessConstants.DATA_EXCHANGE_ORDER_NO_LENTH, '0');
     return (Entity.BusinessConstants.NUMBERCONTROL_CANCELIPDETCONFIRM + numberSuffix);
 }