@Override
  public Response<List<AddressPark>> findParksByIds(List<Long> ids) {
    Response<List<AddressPark>> result = new Response<List<AddressPark>>();

    try {
      if (ids == null || ids.isEmpty()) {
        log.error("ids can not be null");
        result.setError("park.ids.not.null.fail");
        return result;
      }

      List<AddressPark> addressParks = addressParkDao.findByIds(ids);
      if (addressParks == null || addressParks.isEmpty()) {
        log.error("parks not found where ids={}", ids);
        result.setError("parks.not.found");
        return result;
      }

      result.setResult(addressParks);
    } catch (Exception e) {
      log.error("find all park failed, error code={}", Throwables.getStackTraceAsString(e));
      result.setError("find.park.failed");
    }

    return result;
  }
  @Override
  public Response<List<AddressPark>> findAllPark() {
    Response<List<AddressPark>> result = new Response<List<AddressPark>>();

    try {
      result.setResult(addressParkDao.findAllPark());
    } catch (Exception e) {
      log.error("find all park failed, error code={}", Throwables.getStackTraceAsString(e));
      result.setError("find.park.failed");
    }

    return result;
  }
 @Override
 public List<AddressPark> load(Long productId) throws Exception {
   // 查询园区详细信息
   return addressParkDao.findParkByProductId(productId);
 }
  @Override
  public Response<List<ParkFactoryDto>> findDetailFactories(Long productId, List<Long> factoryIds) {
    Response<List<ParkFactoryDto>> result = new Response<List<ParkFactoryDto>>();

    if (productId == null) {
      log.error("find park and factory info need productId");
      result.setError("parkAddress.productId.null");
      return result;
    }

    if (factoryIds == null || factoryIds.isEmpty()) {
      log.error("find park and factory info need factoryIds");
      result.setError("parkAddress.factoryIds.null");
      return result;
    }

    try {
      List<CategoryFactory> categoryFactoryList =
          categoryFactoryDao.findByParams(productId, factoryIds);

      // 园区信息查询结果列表
      List<AddressPark> parkQuery =
          addressParkDao.findByIds(
              Lists.transform(
                  categoryFactoryList,
                  new Function<CategoryFactory, Long>() {
                    @Override
                    public Long apply(CategoryFactory categoryFactory) {
                      return categoryFactory.getParkId();
                    }
                  }));
      Map<Long, AddressPark> parkMap = Maps.newHashMap();
      for (AddressPark addressPark : parkQuery) {
        parkMap.put(addressPark.getId(), addressPark);
      }

      // 工厂信息查询结果列表
      List<AddressFactory> factoryQuery =
          addressFactoryDao.findByFactoryIds(
              Lists.transform(
                  categoryFactoryList,
                  new Function<CategoryFactory, Long>() {
                    @Override
                    public Long apply(CategoryFactory categoryFactory) {
                      return categoryFactory.getFactoryId();
                    }
                  }));
      Map<Long, AddressFactory> factoryMap = Maps.newHashMap();
      for (AddressFactory factory : factoryQuery) {
        factoryMap.put(factory.getId(), factory);
      }

      // 组装园区工厂信息列表
      List<ParkFactoryDto> parkFactoryDtoList = Lists.newArrayList();
      ParkFactoryDto parkFactoryDto;
      AddressPark addressPark;
      AddressFactory addressFactory;
      for (CategoryFactory categoryFactory : categoryFactoryList) {
        parkFactoryDto = new ParkFactoryDto();
        addressPark = parkMap.get(categoryFactory.getParkId());
        addressFactory = factoryMap.get(categoryFactory.getFactoryId());

        parkFactoryDto.setParkId(addressPark.getId());
        parkFactoryDto.setParkName(addressPark.getParkName());
        parkFactoryDto.setFactoryId(addressFactory.getId());
        parkFactoryDto.setFactoryNum(addressFactory.getFactoryNum());
        parkFactoryDto.setFactoryName(addressFactory.getFactoryName());

        parkFactoryDtoList.add(parkFactoryDto);
      }

      result.setResult(parkFactoryDtoList);
    } catch (Exception e) {
      log.error(
          "find park and factory failed , productId={}, factoryIds={}", productId, factoryIds);
      result.setError("find.factory.failed");
    }

    return result;
  }