private List <CompleteDocInfoDTOData> CreateCompleteDocInfos(List <ProductBarCodeByCompleteApplyDTO> barCodeDTOs)
        {
            List <CompleteDocInfoDTOData> docInfoList = new List <CompleteDocInfoDTOData>();
            CompleteDocInfoDTOData        docInfoDTO  = new CompleteDocInfoDTOData();

            docInfoDTO.BusinessDate = Base.Context.LoginDate;
            docInfoDTO.CompleteList = new List <WOInfoDTOData>();
            docInfoList.Add(docInfoDTO);

            foreach (ProductBarCodeByCompleteApplyDTO barCodeDTO in barCodeDTOs)
            {
                ItemMaster           item = new ItemMaster.EntityKey(barCodeDTO.ItemID).GetEntity();
                CompleteApplyDocLine completeApplyDocLine = new CompleteApplyDocLine.EntityKey(barCodeDTO.CompleteApplyDocLine).GetEntity();

                WOInfoDTOData woInfoDTO = new WOInfoDTOData();
                woInfoDTO.CompleteQty = (decimal)(barCodeDTO.ActualLength / 1000.0);
                //生成批号数据
                LotMaster.EntityKey lotKey = LotBuilder.CreateLot(item, barCodeDTO.BarCode, barCodeDTO.ActualLength);
                woInfoDTO.LotMaster = lotKey.ID;
                woInfoDTO.LotNo     = lotKey.GetEntity().LotCode;

                woInfoDTO.MOKey    = new WOKeyData();
                woInfoDTO.MOKey.ID = completeApplyDocLine.MOKey.ID;
                //扩展字段
                woInfoDTO.DescFlexField = GetRcvRptDocLineDescFlexField(completeApplyDocLine);

                docInfoDTO.CompleteList.Add(woInfoDTO);
            }
            return(docInfoList);
        }
        public override object Do(object obj)
        {
            GenProductBarCodesByRMA bpObj = (GenProductBarCodesByRMA)obj;

            if (bpObj.ProductBarCodeDTOs == null || bpObj.ProductBarCodeDTOs.Count == 0)
            {
                return(null);
            }

            //生成销售退回收货单
            CreateReceivementProxy createRcv = new CreateReceivementProxy();

            createRcv.RcvHeadDTOs = CreateRcvHeadDTOs(bpObj.ProductBarCodeDTOs);
            List <BusinessEntity.EntityKey> resultKeys = createRcv.Do();

            if (resultKeys == null || resultKeys.Count == 0)
            {
                return(null);
            }

            using (Session s = Session.Open())
            {
                List <ProductBarCodeByRMADTO> barCodeDTOs = new List <ProductBarCodeByRMADTO>(bpObj.ProductBarCodeDTOs);

                foreach (BusinessEntity.EntityKey resultKey in resultKeys)
                {
                    Receivement rcv = new Receivement.EntityKey(resultKey.ID).GetEntity();
                    foreach (RcvLine rcvLine in rcv.RcvLines)
                    {
                        ProductBarCodeByRMADTO barCodeDTO = FindProductBarCodeDTO(barCodeDTOs, rcvLine);
                        barCodeDTOs.Remove(barCodeDTO);
                        //生成批号数据
                        LotMaster.EntityKey lotKey = LotBuilder.CreateLot(rcvLine.ItemInfo.ItemID, barCodeDTO.BarCode, barCodeDTO.ActualLength);
                        //设置收货行批号
                        SetRcvLineLotInfo(rcvLine, lotKey);
                        //生成成品条码记录
                        ProductBarCode productBarCode = ProductBarCode.Create();
                        productBarCode.OrgKey       = new Base.Organization.Organization.EntityKey(barCodeDTO.OrgID);
                        productBarCode.BarCode      = barCodeDTO.BarCode;
                        productBarCode.ActualLength = barCodeDTO.ActualLength;
                        productBarCode.ItemKey      = rcvLine.ItemInfo.ItemIDKey;
                        productBarCode.LotKey       = lotKey;
                        productBarCode.OperatorsKey = new CBO.HR.Operator.Operators.EntityKey(barCodeDTO.QcOperator);

                        productBarCode.RMAKey             = new SM.RMA.RMA.EntityKey(barCodeDTO.RMA);
                        productBarCode.RMALineKey         = new SM.RMA.RMALine.EntityKey(barCodeDTO.RMALine);
                        productBarCode.ReceivementKey     = rcvLine.ReceivementKey;
                        productBarCode.RcvLineKey         = rcvLine.Key;
                        productBarCode.ProductBarCodeKind = ProductBarCodeKindEnum.RMR;
                    }
                }
                s.Commit();
            }
            return(null);
        }
        public override object Do(object obj)
        {
            GenProductBarCodesByShip bpObj = (GenProductBarCodesByShip)obj;

            if (bpObj.ProductBarCodeDTOs == null || bpObj.ProductBarCodeDTOs.Count == 0)
            {
                return(null);
            }

            //销售订单转调出单
            SOToTransOutBP soToTransOut = new SOToTransOutBP();

            soToTransOut.SOToTransOutDTOs = CreateSOToTransOutDTOs(bpObj.ProductBarCodeDTOs);
            soToTransOut.SplitMergeRule   = new List <string>();
            List <SOToTransOutResultDTO> resultDTOs = soToTransOut.Do();

            if (resultDTOs == null || resultDTOs.Count == 0)
            {
                return(null);
            }

            using (Session s = Session.Open())
            {
                List <ProductBarCodeByShipDTO> barCodeDTOs = new List <ProductBarCodeByShipDTO>(bpObj.ProductBarCodeDTOs);

                foreach (SOToTransOutResultDTO resultDTO in resultDTOs)
                {
                    TransferOut transferOut = new TransferOut.EntityKey(resultDTO.TransOut).GetEntity();
                    foreach (TransOutLine transOutline in transferOut.TransOutLines)
                    {
                        ProductBarCodeByShipDTO barCodeDTO = FindProductBarCodeDTO(barCodeDTOs, transOutline);
                        barCodeDTOs.Remove(barCodeDTO);
                        //生成批号数据
                        LotMaster.EntityKey lotKey = LotBuilder.CreateLot(transOutline.ItemInfo.ItemID, barCodeDTO.BarCode, barCodeDTO.ActualLength);
                        //设置调出行批号
                        SetTransOutLineLotInfo(transOutline, lotKey);
                        //记录来源关系
                        ShipPlanLine shipPlanline = ShipPlanLine.Finder.FindByID(barCodeDTO.ShipPlanLine);
                        transOutline.DescFlexSegments.PrivateDescSeg3 = shipPlanline.ID.ToString();        //来源出货计划行ID
                        transOutline.DescFlexSegments.PrivateDescSeg4 = shipPlanline.ShipPlan.DocNo;       //来源出货计划单号
                        transOutline.DescFlexSegments.PrivateDescSeg5 = shipPlanline.DocLineNo.ToString(); //来源出货计划行号

                        //生成成品条码记录
                        ProductBarCode productBarCode = ProductBarCode.Create();
                        productBarCode.OrgKey       = new Base.Organization.Organization.EntityKey(barCodeDTO.OrgID);
                        productBarCode.BarCode      = barCodeDTO.BarCode;
                        productBarCode.ActualLength = barCodeDTO.ActualLength;
                        productBarCode.ItemKey      = transOutline.ItemInfo.ItemIDKey;
                        productBarCode.LotKey       = lotKey;
                        productBarCode.OperatorsKey = new CBO.HR.Operator.Operators.EntityKey(barCodeDTO.QcOperator);
                        productBarCode.ScanBy       = barCodeDTO.ScanBy;
                        productBarCode.ScanOn       = DateTime.Now; // barCodeDTO.ScanOn;

                        productBarCode.ShipPlanKey        = new ShipPlan.EntityKey(barCodeDTO.ShipPlan);
                        productBarCode.ShipPlanLineKey    = new ShipPlanLine.EntityKey(barCodeDTO.ShipPlanLine);
                        productBarCode.TransferOutKey     = transOutline.TransferOutKey;
                        productBarCode.TransferOutLineKey = transOutline.Key;
                        productBarCode.ProductBarCodeKind = ProductBarCodeKindEnum.Ship;
                    }
                }
                s.Commit();
            }

            return(null);
        }