def addAssetClass(self, data):
        """ 添加资产类别
        """
        lPath = data.get("lpath")
        if not lPath:
            LOG.error("lpath value is empty!!!")
            return -1, u"添加失败"
        lpathList = lPath.split(".")
        nLen = len(lpathList)
        if 1 == nLen:
            # 说明添加资产类别
            assetClass = data.get("add_asset_class")
            assetClassEn = data.get("add_asset_class_en")
            return self.actual_add_asset_type(assetClass, assetClassEn, lpathList, nLen)
        elif 2 == nLen:
            # 添加设备类型
            newAssetType = data.get("new_asset_type")
            newAssetTypeEn = data.get("new_asset_type_en")
            return self.actual_add_asset_type(newAssetType, newAssetTypeEn, lpathList, nLen)
        else:
            try:
                # 添加品牌、型号
                checkList = []
                providerCh = data.get("add_provider")
                providerEn = data.get("add_provider_en")
                modelName = data.get("add_model")
                checkList.append(providerCh)
                checkList.append(providerEn)
                checkList.append(modelName)
                if not all(checkList):
                    LOG.error("add new provider model params are empty!!!")
                    return -1, u"填写内容为空,请检查"

                # 得到对应的资产类型id
                assetTypeName = lpathList[nLen - 1]
                atd = AssetTypeDal()
                assetTypeModel = atd.get_asset_type_id_by_ch_name(assetTypeName)
                assetTypeId = assetTypeModel.id if assetTypeModel else None

                # 添加品牌
                # 判断新添加的品牌是不是已有的品牌
                pd = ProviderDal()
                providerEn = providerEn.upper()
                providerModel = pd.get_prov_by_id_and_at(assetTypeId, providerEn)
                if providerModel:
                    # 现有的品牌,直接添加型号
                    LOG.info("add device provider is have device")
                    # 判断型号是否存在,如果存在,直接return重复,否则添加
                    provId = providerModel.id
                    md = ModelDal()
                    modelD = md.get_model_by_pd_ch(provId, modelName)
                    if modelD:
                        return -1, u"品牌:" + providerEn + "型号:" + modelName + "已经存在,请勿重复添加"
                    else:
                        md.add_model(provId, modelName)
                else:
                    # 新品牌
                    LOG.info("add device provider is new device")
                    pd.add_new_provider(assetTypeId, providerEn, providerCh)
                    md = ModelDal()
                    provModel = pd.get_prov_by_id_and_at(assetTypeId, providerEn)
                    md.add_model(provModel.id, modelName)
                return 0, u"添加成功"
            except Exception as _ex:
                LOG.error("error occured while add provider model: %s" % str(_ex))
                return -1, u"添加失败"
 def get_prov_list_by_atd(self, asset_type_id):
     pd = ProviderDal()
     return pd.get_prov_by_asset_type(asset_type_id)
 def get_prov_id_by_atd_ch(self, asset_type_id, ch_name):
     pd = ProviderDal()
     provModel = pd.get_prov_by_id_and_at(asset_type_id, ch_name)
     return self.actual_return_id_val(provModel)
 def get_prov_name_by_atd_md_num(self, asset_type_id, prov_id):
     pd = ProviderDal()
     provModel = pd.get_prov_name_by_atd_md(asset_type_id, prov_id)
     return self.actual_return_name_val(provModel)