Exemplo n.º 1
0
        //[OperationBehavior]
        public void DoEx(ICommonDataContract commonData, List <UFIDA.U9.Cust.JSDY.BarCode.ProductBarCodeByShipDTOData> productBarCodeDTOs)
        {
            this.CommonData = commonData;
            try
            {
                BeforeInvoke("UFIDA.U9.Cust.JSDY.BarCode.GenProductBarCodesByShip");
                GenProductBarCodesByShip objectRef = new GenProductBarCodesByShip();


                if (productBarCodeDTOs != null)
                {
                    DeSerializeKey(productBarCodeDTOs);
                    List <UFIDA.U9.Cust.JSDY.BarCode.ProductBarCodeByShipDTO> listProductBarCodeDTOs = new List <UFIDA.U9.Cust.JSDY.BarCode.ProductBarCodeByShipDTO>();
                    foreach (UFIDA.U9.Cust.JSDY.BarCode.ProductBarCodeByShipDTOData obj in productBarCodeDTOs)
                    {
                        if (obj == null)
                        {
                            continue;
                        }

                        UFIDA.U9.Cust.JSDY.BarCode.ProductBarCodeByShipDTO child = new UFIDA.U9.Cust.JSDY.BarCode.ProductBarCodeByShipDTO();
                        child.FromEntityData(obj);
                        //值对象应该是依赖主创建的.但此处不是.可能的问题?
                        listProductBarCodeDTOs.Add(child);
                    }
                    objectRef.ProductBarCodeDTOs = listProductBarCodeDTOs;
                }

                //处理返回类型.
                objectRef.Do();                 //没有返回值
            }
            catch (System.Exception e)
            {
                DealException(e);
                throw;
            }
            finally
            {
                FinallyInvoke("UFIDA.U9.Cust.JSDY.BarCode.GenProductBarCodesByShip");
            }
        }
        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);
        }