/// <summary>
        /// 创建修改料品服务的DTO
        /// </summary>
        /// <param name="_itemModule"></param>
        /// <returns></returns>
        private ISVItem.ItemMasterDTO ModifyItemMasterDTO(ItemMaster _itemExists, ItemMasterCustData _itemData, ContextInfo _cxtInfo, bool _isNewVersion)
        {
            ISVItem.BatchQueryItemByDTOSRV srvQueryItemDTO = new ISVItem.BatchQueryItemByDTOSRV();
            List <ISVItem.QueryItemDTO>    lstQueryDTO     = new List <ISVItem.QueryItemDTO>();

            ISVItem.QueryItemDTO dtoExists = new ISVItem.QueryItemDTO();
            dtoExists.ItemMaster    = new CommonArchiveDataDTO();
            dtoExists.ItemMaster.ID = _itemExists.ID;
            lstQueryDTO.Add(dtoExists);

            srvQueryItemDTO.QueryItemDTOs = lstQueryDTO;
            List <ISVItem.ItemMasterDTO> lstItemMasterDTO = srvQueryItemDTO.Do();

            ISVItem.ItemMasterDTO dtoItemModify = null;
            if (lstItemMasterDTO != null && lstItemMasterDTO.Count > 0)
            {
                dtoItemModify       = lstItemMasterDTO[0];
                dtoItemModify.SPECS = _itemData.Specs;//规格
                if (!string.IsNullOrEmpty(_itemData.ItemForm))
                {
                    dtoItemModify.ItemForm = ItemTypeEnum.GetFromValue(_itemData.ItemForm);                       //料品形态
                }
                dtoItemModify.ItemFormAttribute = ItemTypeAttributeEnum.GetFromName(_itemData.ItemFormAttribute); //料品形态属性
                User beUser = User.Finder.FindByID(_cxtInfo.UserID);

                dtoItemModify.ModifiedBy            = beUser.Name;//修改人
                dtoItemModify.ModifiedOn            = DateTime.Now.Date;
                dtoItemModify.Effective.IsEffective = _itemData.Effective;

                //若单位为提供,则沿用原单位
                CommonArchiveDataDTO dtoUOM = new CommonArchiveDataDTO();
                if (String.IsNullOrEmpty(_itemData.UOMCode))
                {
                    dtoUOM.Code = _itemExists.InventoryUOM.Code;
                    dtoUOM.ID   = _itemExists.InventoryUOM.ID;
                    dtoUOM.Name = _itemExists.InventoryUOM.Name;
                }
                else
                {
                    UOM beUOM = UOM.FindByCode(_itemData.UOMCode);
                    dtoUOM.Code = beUOM.Code;
                    dtoUOM.ID   = beUOM.ID;
                    dtoUOM.Name = beUOM.Name;
                }

                dtoItemModify.InventoryUOM       = dtoUOM; //库存主单位
                dtoItemModify.InventorySecondUOM = dtoUOM; //库存单位
                dtoItemModify.BulkUom            = dtoUOM; //体积单位
                dtoItemModify.CostUOM            = dtoUOM; //成本单位
                dtoItemModify.ManufactureUOM     = dtoUOM; //生产单位
                dtoItemModify.MaterialOutUOM     = dtoUOM; //领料单位
                dtoItemModify.PurchaseUOM        = dtoUOM; //采购单位
                dtoItemModify.PriceUOM           = dtoUOM; //计价单位
                dtoItemModify.SalesUOM           = dtoUOM; //销售单位
                dtoItemModify.WeightUom          = dtoUOM; //重量单位

                StringBuilder strbCombName = new StringBuilder();
                strbCombName.AppendFormat("{0}|{1}|{2}|{3}|{4}|{5}|{6}|{7}|{8}|{9}|{10}|{11}|{12}|{13}|{14}|{15}",
                                          string.IsNullOrEmpty(_itemData.ItemName) ? "0" : _itemData.ItemName, string.IsNullOrEmpty(_itemData.Specs) ? "0" : _itemData.Specs,
                                          string.IsNullOrEmpty(_itemData.ItemProperty1) ? "0" : _itemData.ItemProperty1, string.IsNullOrEmpty(_itemData.ItemProperty2) ? "0" : _itemData.ItemProperty2,
                                          string.IsNullOrEmpty(_itemData.ItemProperty3) ? "0" : _itemData.ItemProperty3, string.IsNullOrEmpty(_itemData.ItemProperty4) ? "0" : _itemData.ItemProperty4,
                                          string.IsNullOrEmpty(_itemData.ItemProperty5) ? "0" : _itemData.ItemProperty5, string.IsNullOrEmpty(_itemData.ItemProperty6) ? "0" : _itemData.ItemProperty6,
                                          string.IsNullOrEmpty(_itemData.ItemProperty7) ? "0" : _itemData.ItemProperty7, string.IsNullOrEmpty(_itemData.ItemProperty8) ? "0" : _itemData.ItemProperty8,
                                          string.IsNullOrEmpty(_itemData.ItemProperty9) ? "0" : _itemData.ItemProperty9, string.IsNullOrEmpty(_itemData.ItemProperty10) ? "0" : _itemData.ItemProperty10,
                                          string.IsNullOrEmpty(_itemData.ItemProperty11) ? "0" : _itemData.ItemProperty11, string.IsNullOrEmpty(_itemData.ItemProperty12) ? "0" : _itemData.ItemProperty12,
                                          string.IsNullOrEmpty(_itemData.ItemProperty13) ? "0" : _itemData.ItemProperty13, string.IsNullOrEmpty(_itemData.ItemProperty14) ? "0" : _itemData.ItemProperty14);
                dtoItemModify.Name = strbCombName.ToString();
                //dtoItemModify.Name = _itemData.ItemName;//测试

                #region DescFlexField;扩展字段
                DescFlexSegments segments = dtoItemModify.DescFlexField;
                segments.SetValue("PrivateDescSeg5", _itemData.ItemDescSeg5);
                segments.SetValue("PrivateDescSeg6", _itemData.ItemDescSeg6);
                segments.SetValue("PrivateDescSeg7", _itemData.ItemDescSeg7);
                segments.SetValue("PrivateDescSeg8", _itemData.ItemDescSeg8);
                segments.SetValue("PrivateDescSeg9", _itemData.ItemDescSeg9);
                segments.SetValue("PrivateDescSeg10", _itemData.ItemDescSeg10);
                #endregion

                //无料品版本处理
            }

            return(dtoItemModify);
        }
        /// <summary>
        /// 创建新增料品服务的DTO
        /// </summary>
        /// <param name="_itemModule"></param>
        /// <returns></returns>
        private ISVItem.ItemMasterDTO CreateItemMasterDTO(ISVItem.ItemMasterDTO _dtoItemModule, ItemMasterCustData _itemData, ContextInfo _cxtInfo)
        {
            ISVItem.ItemMasterDTO dtoItemNew = new ISVItem.ItemMasterDTO();
            dtoItemNew.Org = new CommonArchiveDataDTO();//组织
            Organization beOrg = Organization.FindByCode(_cxtInfo.OrgCode);

            dtoItemNew.Org.ID   = beOrg.ID;
            dtoItemNew.Org.Code = beOrg.Code;
            dtoItemNew.Org.Name = beOrg.Name;
            if (!string.IsNullOrEmpty(_itemData.ItemCode))
            {
                dtoItemNew.Code = _itemData.ItemCode;//料号
            }

            dtoItemNew.SPECS             = _itemData.Specs;                                                //规格
            dtoItemNew.ItemFormAttribute = ItemTypeAttributeEnum.GetFromName(_itemData.ItemFormAttribute); //料品形态属性
            //if (ItemTypeAttributeEnum.GetFromName(_itemData.ItemFormAttribute) == ItemTypeAttributeEnum.PurchasePart)
            //{
            //    dtoItemNew.IsBOMEnable = false;//可BOM----采购件,不支持(委外)可BOM母件设定。
            //}
            //else
            //{
            dtoItemNew.IsBOMEnable = _dtoItemModule.IsBOMEnable;                 //可BOM
            //}
            dtoItemNew.ItemForm = ItemTypeEnum.GetFromValue(_itemData.ItemForm); //料品形态

            //不进行料品版本的业务处理
            dtoItemNew.IsVersionQtyControl = false;
            dtoItemNew.ItemMasterVersions  = null;//默认不提供物料版本
            dtoItemNew.Version             = string.Empty;
            dtoItemNew.VersionID           = 0L;

            StringBuilder strbCombName = new StringBuilder();

            strbCombName.AppendFormat("{0}|{1}|{2}|{3}|{4}|{5}|{6}|{7}|{8}|{9}|{10}|{11}|{12}|{13}|{14}|{15}",
                                      string.IsNullOrEmpty(_itemData.ItemName) ? "0" : _itemData.ItemName, string.IsNullOrEmpty(_itemData.Specs) ? "0" : _itemData.Specs,
                                      string.IsNullOrEmpty(_itemData.ItemProperty1) ? "0" : _itemData.ItemProperty1, string.IsNullOrEmpty(_itemData.ItemProperty2) ? "0" : _itemData.ItemProperty2,
                                      string.IsNullOrEmpty(_itemData.ItemProperty3) ? "0" : _itemData.ItemProperty3, string.IsNullOrEmpty(_itemData.ItemProperty4) ? "0" : _itemData.ItemProperty4,
                                      string.IsNullOrEmpty(_itemData.ItemProperty5) ? "0" : _itemData.ItemProperty5, string.IsNullOrEmpty(_itemData.ItemProperty6) ? "0" : _itemData.ItemProperty6,
                                      string.IsNullOrEmpty(_itemData.ItemProperty7) ? "0" : _itemData.ItemProperty7, string.IsNullOrEmpty(_itemData.ItemProperty8) ? "0" : _itemData.ItemProperty8,
                                      string.IsNullOrEmpty(_itemData.ItemProperty9) ? "0" : _itemData.ItemProperty9, string.IsNullOrEmpty(_itemData.ItemProperty10) ? "0" : _itemData.ItemProperty10,
                                      string.IsNullOrEmpty(_itemData.ItemProperty11) ? "0" : _itemData.ItemProperty11, string.IsNullOrEmpty(_itemData.ItemProperty12) ? "0" : _itemData.ItemProperty12,
                                      string.IsNullOrEmpty(_itemData.ItemProperty13) ? "0" : _itemData.ItemProperty13, string.IsNullOrEmpty(_itemData.ItemProperty14) ? "0" : _itemData.ItemProperty14);
            dtoItemNew.Name = strbCombName.ToString();
            //dtoItemNew.Name = _itemData.ItemName;//测试

            User beUser = User.Finder.FindByID(_cxtInfo.UserID);

            dtoItemNew.AliasName  = string.Empty; //别名
            dtoItemNew.CreatedBy  = beUser.Name;  //创建人
            dtoItemNew.CreatedOn  = DateTime.Now.Date;
            dtoItemNew.ModifiedBy = beUser.Name;  //修改人
            dtoItemNew.ModifiedOn = DateTime.Now.Date;

            dtoItemNew.IsMultyUOM = _dtoItemModule.IsMultyUOM;        //多单位
            dtoItemNew.IsDualUOM  = _dtoItemModule.IsDualUOM;         //双单位
            UOM beUOM = UOM.FindByCode(_itemData.UOMCode);
            CommonArchiveDataDTO dtoUOM = new CommonArchiveDataDTO(); //单位

            dtoUOM.Code = beUOM.Code;
            dtoUOM.ID   = beUOM.ID;
            dtoUOM.Name = beUOM.Name;

            dtoItemNew.InventoryUOM       = dtoUOM; //库存主单位
            dtoItemNew.InventorySecondUOM = dtoUOM; //库存单位
            dtoItemNew.BulkUom            = dtoUOM; //体积单位
            dtoItemNew.CostUOM            = dtoUOM; //成本单位
            dtoItemNew.ManufactureUOM     = dtoUOM; //生产单位
            dtoItemNew.MaterialOutUOM     = dtoUOM; //领料单位
            dtoItemNew.PurchaseUOM        = dtoUOM; //采购单位
            dtoItemNew.PriceUOM           = dtoUOM; //计价单位
            dtoItemNew.SalesUOM           = dtoUOM; //销售单位
            dtoItemNew.WeightUom          = dtoUOM; //重量单位

            Effective beEffective = new Effective();

            beEffective.IsEffective   = _itemData.Effective;
            beEffective.EffectiveDate = DateTime.Now.Date;            // _dtoItemModule.Effective.EffectiveDate;
            beEffective.DisableDate   = DateTime.Parse("9999-12-31"); // _dtoItemModule.Effective.DisableDate;
            dtoItemNew.Effective      = beEffective;                  //生效性

            #region dtoItemNew.DescFlexField;扩展字段
            DescFlexSegments segments = new DescFlexSegments();
            segments.SetValue("PrivateDescSeg5", _itemData.ItemDescSeg5);
            segments.SetValue("PrivateDescSeg6", _itemData.ItemDescSeg6);
            segments.SetValue("PrivateDescSeg7", _itemData.ItemDescSeg7);
            segments.SetValue("PrivateDescSeg8", _itemData.ItemDescSeg8);
            segments.SetValue("PrivateDescSeg9", _itemData.ItemDescSeg9);
            segments.SetValue("PrivateDescSeg10", _itemData.ItemDescSeg10);
            dtoItemNew.DescFlexField = segments;
            #endregion

            #region 模板物料赋值
            dtoItemNew.AssetCategory         = _dtoItemModule.AssetCategory;               //财务分类
            dtoItemNew.BoundedCategory       = _dtoItemModule.BoundedCategory;             //保税品类别
            dtoItemNew.BoundedCountTaxRate   = _dtoItemModule.BoundedCountTaxRate;         //保税应补税率
            dtoItemNew.BoundedCountToLerance = _dtoItemModule.BoundedCountToLerance;       //保税盘差率
            dtoItemNew.BoundedTaxNO          = _dtoItemModule.BoundedTaxNO;                //料品税则号

            dtoItemNew.CatalogNO                = _dtoItemModule.CatalogNO;                //目录编号
            dtoItemNew.ConverRatioRule          = _dtoItemModule.ConverRatioRule;          //转换率策略
            dtoItemNew.CostCategory             = _dtoItemModule.CostCategory;             //成本分类
            dtoItemNew.CostCurrency             = _dtoItemModule.CostCurrency;             //成本币种
            dtoItemNew.CreditCategory           = _dtoItemModule.CreditCategory;           //信用分类
            dtoItemNew.CustomNumber             = _dtoItemModule.CustomNumber;             //海关编码
            dtoItemNew.CustomTaxRate            = _dtoItemModule.CustomTaxRate;            //海关增税率
            dtoItemNew.DrawbackRate             = _dtoItemModule.DrawbackRate;             //退税率
            dtoItemNew.EndGrade                 = _dtoItemModule.EndGrade;                 //结束等级
            dtoItemNew.EndPotency               = _dtoItemModule.EndPotency;               //结束成分
            dtoItemNew.EntranceInfo             = _dtoItemModule.EntranceInfo;             //进出口信息
            dtoItemNew.InspectionInfo           = _dtoItemModule.InspectionInfo;           //料品质量相关信息
            dtoItemNew.InternalTransCost        = _dtoItemModule.InternalTransCost;        //内部转移成本
            dtoItemNew.InventoryInfo            = _dtoItemModule.InventoryInfo;            //料品库存相关信息
            dtoItemNew.InventoryUOMGroup        = _dtoItemModule.InventoryUOMGroup;        //库存主单位计量单位组
            dtoItemNew.IsBounded                = _dtoItemModule.IsBounded;                //保税品
            dtoItemNew.IsBuildEnable            = _dtoItemModule.IsBuildEnable;            //可生产
            dtoItemNew.IsCanFlowStat            = _dtoItemModule.IsCanFlowStat;            //可流向统计
            dtoItemNew.IsDualQuantity           = _dtoItemModule.IsDualQuantity;           //双数量
            dtoItemNew.IsGradeControl           = _dtoItemModule.IsGradeControl;           //等级控制
            dtoItemNew.IsIncludedCostCa         = _dtoItemModule.IsIncludedCostCa;         //成本卷算
            dtoItemNew.IsIncludedStockAsset     = _dtoItemModule.IsIncludedStockAsset;     //存货资产
            dtoItemNew.IsInventoryEnable        = _dtoItemModule.IsInventoryEnable;        //可库存交易
            dtoItemNew.IsMRPEnable              = _dtoItemModule.IsMRPEnable;              //可MRP
            dtoItemNew.IsNeedLicence            = _dtoItemModule.IsNeedLicence;            //需许可证
            dtoItemNew.IsOutsideOperationEnable = _dtoItemModule.IsOutsideOperationEnable; //可委外
            dtoItemNew.IsPotencyControl         = _dtoItemModule.IsPotencyControl;         //成分控制
            dtoItemNew.IsPurchaseEnable         = _dtoItemModule.IsPurchaseEnable;         //可采购
            dtoItemNew.IsSalesEnable            = _dtoItemModule.IsSalesEnable;            //可销售
            dtoItemNew.IsSpecialItem            = _dtoItemModule.IsSpecialItem;            //专用料
            dtoItemNew.IsTrademark              = _dtoItemModule.IsTrademark;              //厂牌管理
            dtoItemNew.IsVarRatio               = _dtoItemModule.IsVarRatio;               //固定转换率
            //dtoItemNew.IsVersionQtyControl = _dtoItemModule.IsVersionQtyControl;//版本数量控制
            dtoItemNew.IsVMIEnable = _dtoItemModule.IsVMIEnable;                           //VMI标志
            dtoItemNew.ItemBulk    = _dtoItemModule.ItemBulk;                              //库存单位体积
            //dtoItemNew.ItemForm = _dtoItemModule.ItemForm;//料品形态
            dtoItemNew.ItemTradeMarkInfos = _dtoItemModule.ItemTradeMarkInfos;             //料品厂牌信息

            //dtoItemNew.MainItemCategory = _dtoItemModule.MainItemCategory;//主分类
            dtoItemNew.MainItemCategory      = new CommonArchiveDataDTO();
            dtoItemNew.MainItemCategory.Code = _itemData.MainCategoryCode;

            dtoItemNew.MfgInfo = _dtoItemModule.MfgInfo;                                 //料品生产相关信息
            //MRPPlanningType  计划方法
            dtoItemNew.MrpInfo = _dtoItemModule.MrpInfo;                                 //料品MRP相关信息
            dtoItemNew.MrpInfo.MRPPlanningType = _dtoItemModule.MrpInfo.MRPPlanningType; //计划方法
            dtoItemNew.MRPCategory             = _dtoItemModule.MRPCategory;             //MRP分类
            dtoItemNew.NeedInspect             = _dtoItemModule.NeedInspect;             //需商检
            dtoItemNew.PlanCost      = _dtoItemModule.PlanCost;                          //计划价
            dtoItemNew.PriceCategory = _dtoItemModule.PriceCategory;                     //价格分类

            dtoItemNew.ProductionCategory      = _dtoItemModule.ProductionCategory;      //生产分类
            dtoItemNew.PurchaseCategory        = _dtoItemModule.PurchaseCategory;        //采购分类
            dtoItemNew.PurchaseInfo            = _dtoItemModule.PurchaseInfo;            //料品采购相关信息
            dtoItemNew.RecentlyCost            = _dtoItemModule.RecentlyCost;            //最新成本
            dtoItemNew.RefrenceCost            = _dtoItemModule.RefrenceCost;            //参考成本
            dtoItemNew.SaleCategory            = _dtoItemModule.SaleCategory;            //销售分类
            dtoItemNew.SaleInfo                = _dtoItemModule.SaleInfo;                //料品销售相关信息
            dtoItemNew.SaleInfo.ItemForInvoice = new CommonArchiveDataDTO();
            dtoItemNew.SaleInfo.NameForInvoice = strbCombName.ToString();

            dtoItemNew.StandardBatchQty = _dtoItemModule.StandardBatchQty; //标准批量
            dtoItemNew.StandardCost     = _dtoItemModule.StandardCost;     //标准成本
            dtoItemNew.StandardGrade    = _dtoItemModule.StandardGrade;    //标准等级
            dtoItemNew.StandardPotency  = _dtoItemModule.StandardPotency;  //标准成分
            dtoItemNew.StartGrade       = _dtoItemModule.StartGrade;       //起始等级
            dtoItemNew.StartPotency     = _dtoItemModule.StartPotency;     //起始成分
            dtoItemNew.State            = _dtoItemModule.State;            //料品状态
            dtoItemNew.StateTime        = _dtoItemModule.StateTime;        //状态提交日期
            dtoItemNew.StateUser        = _dtoItemModule.StateUser;        //提交人
            dtoItemNew.Status           = _dtoItemModule.Status;           //状态码
            dtoItemNew.StatusLastModify = DateTime.Now.Date;               //状态日期
            dtoItemNew.StockCategory    = _dtoItemModule.StockCategory;    //库存分类
            dtoItemNew.TradeMark        = _dtoItemModule.TradeMark;        //厂牌
            dtoItemNew.Weight           = _dtoItemModule.Weight;           //库存单位重量
            #endregion

            return(dtoItemNew);
        }