package com.bocloud.ims.service.resource;

import com.alibaba.fastjson.JSONObject;
import com.bocloud.cmp.driver.compute.ServerDriver;
import com.bocloud.cmp.driver.secuirty.KeypairDriver;
import com.bocloud.cmp.entity.enums.CloudProvider;
import com.bocloud.cmp.model.KeypairModel;
import com.bocloud.cmp.model.ServerModel;
import com.bocloud.common.model.BocloudResult;
import com.bocloud.common.model.GridBean;
import com.bocloud.common.model.OperateResult;
import com.bocloud.common.model.Pager;
import com.bocloud.common.model.Param;
import com.bocloud.common.model.RequestContext;
import com.bocloud.common.model.RequestContext.Catalog;
import com.bocloud.common.model.Sign;
import com.bocloud.common.model.SimpleBean;
import com.bocloud.common.utils.Common;
import com.bocloud.common.utils.GridHelper;
import com.bocloud.common.utils.ListTool;
import com.bocloud.common.utils.MapTools;
import com.bocloud.ims.entity.resource.CloudServer;
import com.bocloud.ims.entity.resource.CloudVendor;
import com.bocloud.ims.entity.resource.Firewall;
import com.bocloud.ims.entity.resource.Keypair;
import com.bocloud.ims.entity.resource.OSTenant;
import com.bocloud.ims.entity.resource.ResourceGroup;
import com.bocloud.ims.entity.resource.ServerKeypair;
import com.bocloud.ims.entity.resource.manageone.ManageOneAccount;
import com.bocloud.ims.interfaces.manageone.ManageOneAccountService;
import com.bocloud.ims.interfaces.resource.KeypairService;
import com.bocloud.ims.interfaces.resource.ResourcePoolService;
import com.bocloud.ims.interfaces.resource.VendorProjectService;
import com.bocloud.ims.repository.resource.CloudServerRepository;
import com.bocloud.ims.repository.resource.CloudVendorRepository;
import com.bocloud.ims.repository.resource.KeypairRepository;
import com.bocloud.ims.repository.resource.OSTenantRepository;
import com.bocloud.ims.repository.resource.ResourceGroupRepository;
import com.bocloud.ims.repository.resource.ServerKeypairRepository;
import com.bocloud.ims.service.utils.ResourceEventPublisher;
import com.bocloud.service.lock.BocloudACLock;
import com.bocloud.service.lock.LockFactory;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.Assert;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.concurrent.TimeUnit;

/**
 * 密钥service实现
 *
 * @author wangyu
 * @version 1.0
 * @since 2017年10月12日
 */
@Service("keypairService")
public class KeypairServiceImpl implements KeypairService {

	private static Logger logger = LoggerFactory.getLogger(KeypairServiceImpl.class);

	@Autowired
	private KeypairRepository keypairRepository;
	@Autowired
	private CloudVendorRepository cloudVendorRepository;
	@Autowired
	private KeypairDriver keypairDriver;
	@Autowired
	private ResourceEventPublisher resourceEventPublisher;
	@Autowired
	private LockFactory lockFactory;
	@Autowired
	private ServerKeypairRepository serverKeypairRepository;
	@Autowired
	private ServerDriver serverDriver;
	@Autowired
	private CloudServerRepository cloudserverRepository;
	@Autowired
	private VendorProjectService vendorProjectService;
	@Autowired
	private ManageOneAccountService accountService;
	@Autowired
	private ResourceGroupRepository resourceGroupRepository;
	@Autowired
	private ResourcePoolService resourcePoolService;
	@Autowired
	private OSTenantRepository osTenantRepository;

	@Override
	public BocloudResult<GridBean<Keypair>> list(Pager pager, RequestContext context) {
		try {
			GridBean gridBean = null;
			List<Param> params = Optional.ofNullable(pager.getParams()).orElse(new ArrayList<>());
			Map<String, String> sorter = Optional.ofNullable(pager.getSorter()).orElse(Maps.newHashMap());
			Boolean simple = Optional.ofNullable(pager.getSimple()).orElse(false);
			sorter.put("gmtCreate", Common.ONE);
			Integer page = Optional.ofNullable(pager.getPage()).orElse(1);
			Integer rows = Optional.ofNullable(pager.getRows()).orElse(10);
			int total = 0;
			Catalog catalog = context.getCatalog();
			// 自服务查询
			if (Catalog.Tenant == catalog || Catalog.User == catalog) {
				String vendorType = null;
				Long vendorId = null;
				for (Param param : params) {
					Map<String, Object> paramMap = param.getParam();
					if (paramMap.containsKey("vendorType")) {
						vendorType = String.valueOf(paramMap.get("vendorType"));
						paramMap.remove("vendorType");
					} else if (paramMap.containsKey("vendorId")) {
						if (Sign.EQ == param.getSign()) {
							vendorId = Long.valueOf(paramMap.get("vendorId").toString()) ;
						}
					}
				}

				Long tenantId = context.getTenant();
				List<Long> tenantVendorIds = resourcePoolService.listTenantVendorIds(tenantId, vendorType);
				tenantVendorIds.add(-1L);

				String vendorTypeFromCloudVendor = null;
				if (vendorId != null && vendorId > 0) {
					List<Long> vendorIds = new ArrayList<>(1);
					vendorIds.add(vendorId);
					List<CloudVendor> vendorList = cloudVendorRepository.listByIds(vendorIds);
					CloudVendor cloudVendor = null;
					if (vendorList != null && !vendorList.isEmpty()) {
						cloudVendor = vendorList.get(0);
					}
					if (cloudVendor != null) {
						vendorTypeFromCloudVendor = cloudVendor.getType();
					}
				}

				boolean addTenantId = true;
				if (CloudProvider.AWS.name().equals(vendorTypeFromCloudVendor)) {
					//AWS密钥没有分配给租户的功能
					addTenantId = false;
				}

				// 添加租户过滤
				if (addTenantId) {
					params.add(new Param(MapTools.simpleMap("tenant_id", context.getTenant()), Sign.EQ));
				}

				total = keypairRepository.count(params, tenantVendorIds);
				List<Keypair> list = this.keypairRepository.list(page, rows, params, sorter, tenantVendorIds);
				// 添加秘钥绑定云主机数量
				if (!ListTool.isEmpty(list)) {
					this.bindInstancesCount(list);
				}
				gridBean = GridHelper.getBean(page, rows, total, list);
			} else {
				total = keypairRepository.count(params);
				if (simple) {
					List<SimpleBean> beans = keypairRepository.list(params, sorter);
					gridBean = new GridBean(1, 1, total, beans);
				} else {
					List<Keypair> list = this.keypairRepository.list(page, rows, params, sorter);
					// 添加秘钥绑定云主机数量
					if (!ListTool.isEmpty(list)) {
						this.bindInstancesCount(list);
					}
					// 添加azure 资源组名称
					for (Keypair keypair : list) {
						if (null != keypair.getResourceGroupId()) {
							Optional.ofNullable(resourceGroupRepository.query(keypair.getResourceGroupId()))
									.map(ResourceGroup::getName).ifPresent(keypair::setResourceGroupName);
						}
					}
					gridBean = GridHelper.getBean(page, rows, total, list);
				}
			}
			return new BocloudResult<>(true, gridBean, "查询成功");
		} catch (Exception e) {
			logger.error("list keypair failure:", e);
			return new BocloudResult<>(false, "查询失败");
		}
	}

	private void bindInstancesCount(List<Keypair> list) throws Exception {
		for (Keypair keypair : list) {
			List<ServerKeypair> serverKeypair = serverKeypairRepository.listByKeypairId(keypair.getId());
			if (null != serverKeypair && !serverKeypair.isEmpty()) {
				keypair.setInstancesCount(serverKeypair.size());
			}
			if (CloudProvider.HUAWEI.name().equalsIgnoreCase(keypair.getVendorType())
				|| CloudProvider.HCSO.name().equalsIgnoreCase(keypair.getVendorType())) {
				keypair.setInstancesCount(cloudserverRepository.listByKeyName(keypair.getVendorId(), keypair.getName()));
			}
		}
	}

	@Override
	public BocloudResult create(Keypair keypair, RequestContext context) {
		try {
			// 密钥名称是否重复
			Keypair exist = keypairRepository.getByName(keypair.getName(), keypair.getVendorId());
			if (null != exist) {
				logger.info("keypair name already exists");
				return new BocloudResult<>(false, "密钥名称已经存在");
			}
			String regionId = keypair.getRegionId();
			CloudVendor vendor = cloudVendorRepository.query(keypair.getVendorId());
			if (null == vendor) {
				logger.info("cloud vendor is not exist!");
				return new BocloudResult<>(false, "云平台不存在");
			}
			// 公钥,如果没有指定公钥将会自动生成公钥
			String publicKey = StringUtils.isEmpty(keypair.getPublicKey()) ? null : keypair.getPublicKey();
			BocloudResult bocloudResult = null;
			if (CloudProvider.MANAGEONE.name().equals(vendor.getType()) && null != context.getTenant()
					&& 0L != context.getTenant()) {
				ManageOneAccount account = accountService.queryAccount(vendor.getId(), context.getTenant());
				Assert.notNull(account, "认证失败！");
				bocloudResult = keypairDriver.create(keypair.getName(), publicKey, vendor.getUuid(),
						account.getUsername(), account.getPassword(), account.getProjectId(), account.getDomainName());
			} else if (CloudProvider.ALIYUN.name().equalsIgnoreCase(vendor.getType())) {
				KeypairModel model = new KeypairModel();
				model.setResourceGroupUuid(keypair.getResourceGroupUuid());
				model.setName(keypair.getName());
				model.setPublicKey(publicKey);
				bocloudResult = keypairDriver.create(model, vendor.getUuid(), keypair.getRegionId());
			} else if (CloudProvider.AZURE.name().equals(vendor.getType())) {
				ResourceGroup resourceGroup = resourceGroupRepository.query(keypair.getResourceGroupId());
				if (null == resourceGroup) {
					logger.info("resourceGroup is not exist!");
					return new BocloudResult(false, "资源组不存在！");
				}
				KeypairModel keypairModel = new KeypairModel();
				keypairModel.setRegionId(keypair.getRegionId());
				keypairModel.setName(keypair.getName());
				keypairModel.setPublicKey(publicKey);
				keypairModel.setResourceGroupName(resourceGroup.getName());
				bocloudResult = keypairDriver.create(keypairModel, vendor.getUuid(), keypair.getRegionId());
			} else {
				OSTenant osTenant = osTenantRepository.getByTenantId(context.getTenant(), vendor.getId());
				if (null == osTenant) {
					bocloudResult = keypairDriver.create(keypair.getName(), publicKey, vendor.getUuid(),
							keypair.getRegionId());
				} else {
					bocloudResult = keypairDriver.createByProject(keypair.getName(), publicKey, vendor.getUuid(),
							osTenant.getName(), keypair.getRegionId());
				}
			}
			if (bocloudResult.isFailed()) {
				return new BocloudResult<>(false, bocloudResult.getMessage());
			}
			KeypairModel model = JSONObject.parseObject(JSONObject.toJSONString(bocloudResult.getData()),
					KeypairModel.class);
			BeanUtils.copyProperties(model, keypair);
			keypair.setCreatorId(context.getTarget());
			keypair.setTenantId(context.getTenant());
			keypair.setProjectId(context.getProject());
			keypair.setRegionId(regionId);
			// 保存密钥
			keypairRepository.save(keypair);
			return new BocloudResult<>(true, keypair.getId(), "创建密钥成功");
		} catch (Exception e) {
			logger.info("create keypair fail:", e);
			return new BocloudResult<>(false, "", "创建密钥失败：" + e.getMessage());
		}
	}

	@Override
	public BocloudResult remove(Long id, RequestContext context) {
		String path = Firewall.class.getSimpleName() + "_" + id;
		try (BocloudACLock lock = lockFactory.getACLock(path)) {
			Assert.isTrue(lock.acquire(10, TimeUnit.SECONDS), "请求超时");
			Keypair keypair = keypairRepository.query(id);
			if (null == keypair) {
				logger.info("keypair is not exist!");
				return new BocloudResult<>(false, "密钥不存在");
			}
			CloudVendor vendor = cloudVendorRepository.query(keypair.getVendorId());
			if (null == vendor) {
				logger.info("cloud vendor is not exist!");
				return new BocloudResult<>(false, "云平台不存在");
			}
			String name = keypair.getName();
			if (CloudProvider.TENCENT.name().equals(vendor.getType())
					|| CloudProvider.TCE.name().equals(vendor.getType())) {
				name = keypair.getFingerprint();
				List<ServerKeypair> serverKeypairList = serverKeypairRepository.listByKeypairId(keypair.getId());
				if (null != serverKeypairList && serverKeypairList.size() > 0) {
					logger.info("bind instances is not null !");
					return new BocloudResult<>(false, "当前秘钥已绑定云主机，删除失败");
				}
			}
			if (CloudProvider.QCLOUD.name().equals(vendor.getType())
					|| CloudProvider.PQCLOUD.name().equals(vendor.getType())) {
				name = keypair.getFingerprint();
			}
			// 删除密钥
			BocloudResult bocloudResult = null;
			if (CloudProvider.MANAGEONE.name().equals(vendor.getType()) && null != context.getTenant()
					&& 0L != context.getTenant()) {
				ManageOneAccount account = accountService.queryAccount(vendor.getId(), context.getTenant());
				Assert.notNull(account, "认证失败！");
				bocloudResult = keypairDriver.remove(keypair.getName(), vendor.getUuid(), account.getUsername(),
						account.getPassword(), account.getProjectId(), account.getDomainName());
			} else if (CloudProvider.AZURE.name().equals(vendor.getType())) {
				List<ServerKeypair> serverKeypairList = serverKeypairRepository.listByKeypairId(keypair.getId());
				if (null != serverKeypairList && serverKeypairList.size() > 0) {
					logger.info("bind instances is not null !");
					return new BocloudResult(false, "当前秘钥已绑定云主机，删除失败");
				}
				ResourceGroup resourceGroup = resourceGroupRepository.query(keypair.getResourceGroupId());
				if (null == resourceGroup) {
					logger.info("resourceGroup is not exist!");
					return new BocloudResult(false, "资源组不存在！");
				}
				KeypairModel keypairModel = new KeypairModel();
				keypairModel.setRegionId(keypair.getRegionId());
				keypairModel.setName(keypair.getName());
				keypairModel.setResourceGroupName(resourceGroup.getName());
				bocloudResult = keypairDriver.delete(keypairModel, vendor.getUuid(), keypair.getRegionId());
			} else {
				bocloudResult = keypairDriver.remove(name, vendor.getUuid(), keypair.getRegionId());
			}
			// 删除密钥
			if (bocloudResult.isFailed()) {
				return new BocloudResult<>(false, bocloudResult.getMessage());
			}
			// 删除本地密钥记录
			Boolean flag = keypairRepository.remove(id, context.getTarget());
			if (flag) {
				return new BocloudResult<>(true, "删除成功");
			}
			return new BocloudResult<>(false, "删除失败");
		} catch (Exception e) {
			logger.error("remove keypair fail:", e);
			return new BocloudResult<>(false, "删除密钥失败");
		}
	}

	@Override
	public BocloudResult<Keypair> detail(Long id) {
		try {
			Keypair keypair = keypairRepository.query(id);
			return new BocloudResult<Keypair>(true, keypair, "查询成功");
		} catch (Exception e) {
			logger.error("query keypair fail:", e);
			return new BocloudResult<Keypair>(false, "查询密钥失败");
		}
	}

	@Override
	public BocloudResult<Keypair> getPrivateKey(Long id) {
		try {
			Keypair keypair = keypairRepository.getPrivateKey(id);
			return new BocloudResult<Keypair>(true, keypair, "查询成功");
		} catch (Exception e) {
			logger.error("query keypair fail:", e);
			return new BocloudResult<Keypair>(false, "查询密钥失败");
		}
	}

	@Override
	public BocloudResult<Keypair> modify(Keypair keypairParam, RequestContext context) {
		try {
			Assert.notNull(keypairParam, "参数格式错误");
			Long id = keypairParam.getId();
			String keyPairName = keypairParam.getName();
			Keypair keypair = keypairRepository.query(id);
			if (null == keypair) {
				return new BocloudResult<Keypair>(false, "秘钥信息不存在！");
			}
			Long vendorId = keypair.getVendorId();
			CloudVendor cloudVendor = cloudVendorRepository.query(vendorId);
			Assert.notNull(cloudVendor, "云平台不存在");

			KeypairModel keypairModel = new KeypairModel();
			keypairModel.setKeyId(keypair.getFingerprint());
			keypairModel.setName(keyPairName);
			BocloudResult bocloudResult = keypairDriver.modify(keypairModel, cloudVendor.getUuid(),
					keypair.getRegionId());
			if (null != bocloudResult && bocloudResult.isSuccess()) {
				keypair.setName(keyPairName);
				keypairRepository.update(keypair);
				return new BocloudResult<Keypair>(true, keypair, "修改成功");
			} else {
				return new BocloudResult<Keypair>(false, "编辑失败！");
			}

		} catch (Exception e) {
			logger.error("modify keypair fail:", e);
			return new BocloudResult<Keypair>(false, "密钥修改失败:" + e.getMessage());
		}
	}

	@Override
	public BocloudResult exist(String name, Long vendorId) {
		try {
			// 密钥名称是否重复
			Keypair exist = keypairRepository.getByName(name, vendorId);
			if (null != exist) {
				return new BocloudResult<>(false, "此名称已存在");
			}
			return new BocloudResult<>(true, "");
		} catch (Exception e) {
			logger.error("query keypair fail:", e);
			return new BocloudResult<>(false, "查询密钥失败");
		}
	}

	@Override
	public BocloudResult batchBindServer(Keypair keypairParam, RequestContext context) {
		try {
			Long keypairId = keypairParam.getId();
			Keypair keypair = keypairRepository.query(keypairId);
			Assert.notNull(keypairParam, "密钥不存在");
			Long vendorId = keypair.getVendorId();
			CloudVendor vendor = cloudVendorRepository.query(vendorId);
			if (null == vendor) {
				return new BocloudResult<>(false, "平台信息错误");
			}
			List<Long> serverIdsList = keypairParam.getServerIds();
			List<CloudServer> bindServerArray = new ArrayList<>();
			for (Long serverId : serverIdsList) {
				CloudServer cloudServer = cloudserverRepository.query(serverId);
				if (null == cloudServer || !"STOPPED".equals(cloudServer.getStatus())) {
					return new BocloudResult<>(false, " 云主机没有处于关机状态！");
				}
				bindServerArray.add(cloudServer);
			}
			new Thread(() -> {
				String content = "绑定操作成功";
				String operate = vendor.getType().toLowerCase() + ".keypair";
				Boolean flag = true;
				try {
					// 解绑云主机
					List<CloudServer> cloudServerList = cloudserverRepository.listByKeypair(keypair.getId());
					if (null != cloudServerList && cloudServerList.size() > 0) {
						for (CloudServer cloudServer : cloudServerList) {
							if (null == cloudServer || !"STOPPED".equals(cloudServer.getStatus())) {
								flag = false;
								content = " 处于开机状态，不可以进行此操作！";
								break;
							}
							ServerModel serverUnBindModel = new ServerModel();
							serverUnBindModel.setKeypairIds(new String[] { keypair.getFingerprint() });
							serverUnBindModel.setInstanceIds(new String[] { cloudServer.getInstanceId() });
							BocloudResult bocloudResult = serverDriver.unbindKeypair(serverUnBindModel,
									vendor.getUuid(), cloudServer.getRegionId());
							if (bocloudResult.isFailed()) {
								content = "【" + cloudServer.getName() + "】解绑失败！失败原因： " + bocloudResult.getMessage()
										+ "\n";
								flag = false;
							}
						}
						if (flag) {
							// 删除绑定关系
							serverKeypairRepository.removeBySgid(keypairId);
							if (null != bindServerArray && bindServerArray.size() > 0) {
								Thread.sleep(8000);
							}
						}
					}
					// 绑定云主机
					if (flag && null != bindServerArray && bindServerArray.size() > 0) {
						content = "";
						Thread.sleep(8000);
						for (CloudServer cloudServer : bindServerArray) {
							ServerModel serverBindModel = new ServerModel();
							serverBindModel.setKeypairIds(new String[] { keypair.getFingerprint() });
							serverBindModel.setInstanceIds(new String[] { cloudServer.getInstanceId() });
							BocloudResult bocloudResult = serverDriver.bindKeypair(serverBindModel, vendor.getUuid(),
									cloudServer.getRegionId());
							if (bocloudResult.isSuccess()) {
								ServerKeypair serverKeypair = new ServerKeypair();
								serverKeypair.setKeypairId(keypairId);
								serverKeypair.setServerId(cloudServer.getId());
								serverKeypairRepository.save(serverKeypair);
								content += "【" + cloudServer.getName() + "】绑定成功！\n";
							} else {
								content += "【" + cloudServer.getName() + "】绑定失败！失败原因： " + bocloudResult.getMessage()
										+ "\n";
								flag = false;
							}
						}
					}
				} catch (Exception e) {
					content = e.getMessage();
				}
				resourceEventPublisher.send(
						new OperateResult(flag, content, operate, MapTools.simpleMap(Common.VENDORID, vendor.getId()),
								OperateResult.OperateCategory.ResourceEvent, context));
			}).start();

			return new BocloudResult<>(true, "正在执行批量绑定操作");
		} catch (Exception e) {
			logger.error("绑定云主机:", e);
			return new BocloudResult<>(false, "批量绑定异常：" + e.getMessage());
		}
	}

	@Override
	public BocloudResult batchRemove(List<Long> idArray, RequestContext context) {
		try {
			if (ListTool.isEmpty(idArray)) {
				return new BocloudResult<>(false, "没有需要删除的秘钥信息！");
			}
			Keypair keypair = keypairRepository.query(idArray.get(0));
			if (null == keypair) {
				return new BocloudResult<>(false, "秘钥数据异常！");
			}
			CloudVendor vendor = cloudVendorRepository.query(keypair.getVendorId());
			if (null == vendor) {
				return new BocloudResult<>(false, "平台信息异常！");
			}
			new Thread(new Runnable() {
				@Override
				public void run() {
					String operate = vendor.getType().toLowerCase() + ".keypair";
					try {
						List<BocloudResult> succList = Lists.newArrayList();
						List<BocloudResult> failList = Lists.newArrayList();
						for (Long id : idArray) {
							BocloudResult bocloudResult = remove(id, context);
							if (bocloudResult.isSuccess()) {
								succList.add(bocloudResult);
							} else {
								failList.add(bocloudResult);
							}
						}
						// 删除成功的数量
						int success = succList.size();
						// 删除失败的数量
						int fail = failList.size();
						String content = null;
						if (fail == idArray.size()) {
							content = "秘钥批量删除失败，详情如下：\n";
							for (BocloudResult bocloudResult : failList) {
								content += bocloudResult.getMessage() + "\n";
							}
						} else if (success == idArray.size()) {
							content = "秘钥批量删除成功【" + success + "】个！";
						} else {
							content = "秘钥批量删除成功【" + success + "】个,失败【" + fail + "】个，失败详情如下：\n";
							for (int i = 0; i < failList.size(); i++) {
								content += "【" + i + 1 + "】" + failList.get(i).getMessage() + "\n";
							}
						}
						resourceEventPublisher.send(new OperateResult(fail == idArray.size() ? false : true, content,
								operate, MapTools.simpleMap("vendorId", vendor.getId()),
								OperateResult.OperateCategory.ResourceEvent, context));
					} catch (Exception e) {
						logger.error("秘钥批量删除异常：" + e.getMessage());
						resourceEventPublisher.send(new OperateResult(false, "秘钥批量删除异常：" + e.getMessage(), operate,
								MapTools.simpleMap("vendorId", vendor.getId()),
								OperateResult.OperateCategory.ResourceEvent, context));
					}
				}
			}).start();
			return new BocloudResult<>(true, "批量删除任务已下发，正在执行...");
		} catch (Exception e) {
			logger.error("batch remove keypair fail:", e);
			return new BocloudResult<>(false, "批量删除任务下发失败");
		}
	}

	@Override
	public BocloudResult condition(String condition, RequestContext context) {
		condition = Optional.ofNullable(condition).orElse("");
		JSONObject object = JSONObject.parseObject(condition);
		if ("exist".equalsIgnoreCase(object.getString("condition"))) {
			return this.exist(object.getString(Common.NAME), object.getLong(Common.VENDORID));
		}
		return new BocloudResult<>(false, "参数格式错误");
	}
}
