@Override
  public Response<SupplierInfoChanged> checkSupplierInfoChanged(Long userId) {
    Response<SupplierInfoChanged> result = new Response<SupplierInfoChanged>();
    if (userId == null) {
      log.error("use id can not be null");
      result.setError("user.id.not.null.fail");
      return result;
    }

    try {

      SupplierInfoChanged supplierInfoChanged = new SupplierInfoChanged();
      supplierInfoChanged.setCompanyChanged(
          supplierChangedInfoRedisDao.tabInfoChanged(userId, ChangedInfoKeys.companyTab()));
      supplierInfoChanged.setPaperworkChanged(
          supplierChangedInfoRedisDao.tabInfoChanged(userId, ChangedInfoKeys.paperworkTab()));
      supplierInfoChanged.setContactInfoChanged(
          supplierChangedInfoRedisDao.tabInfoChanged(userId, ChangedInfoKeys.contactInfoTab()));
      supplierInfoChanged.setFinanceChanged(
          supplierChangedInfoRedisDao.tabInfoChanged(userId, ChangedInfoKeys.financeTab()));
      supplierInfoChanged.setQualityChanged(
          supplierChangedInfoRedisDao.tabInfoChanged(userId, ChangedInfoKeys.qualityTab()));

      result.setResult(supplierInfoChanged);
    } catch (Exception e) {
      log.error(
          "fail to check supplier info changed where userId={},cause:{}",
          userId,
          Throwables.getStackTraceAsString(e));
      result.setError("check.supplier.info.changed.fail");
    }

    return result;
  }
  @Override
  public SupplierUpdatedInfoDto<CompanyDto> getNewBaseCompany(
      Long userId,
      Company oldCompany,
      List<CompanyMainBusiness> oldMainBusinesses,
      List<CompanySupplyPark> oldSupplyParks) {
    SupplierUpdatedInfoDto<CompanyDto> supplierUpdatedInfoDto =
        new SupplierUpdatedInfoDto<CompanyDto>();
    CompanyDto companyDto = new CompanyDto();
    Map<String, Object> oldValues = Maps.newHashMap();

    boolean baseCompanyInfoChanged =
        supplierChangedInfoRedisDao.tabInfoChanged(userId, ChangedInfoKeys.companyTab());
    if (!baseCompanyInfoChanged) {
      companyDto.setCompany(oldCompany);
      companyDto.setCompanyMainBusinesses(oldMainBusinesses);
      companyDto.setCompanySupplyParks(oldSupplyParks);

      supplierUpdatedInfoDto.setSupplierInfo(companyDto);
      supplierUpdatedInfoDto.setOldValues(oldValues);
      return supplierUpdatedInfoDto;
    }

    Map<String, String> changedInfo = supplierChangedInfoRedisDao.getChangedInfos(userId);
    Company newCompany = new Company();
    BeanMapper.copy(oldCompany, newCompany);

    if (changedInfo.containsKey(ChangedInfoKeys.companyCorporation())) {
      newCompany.setCorporation(changedInfo.get(ChangedInfoKeys.companyCorporation()));
      oldValues.put(ChangedInfoKeys.companyCorporation(), oldCompany.getCorporation());
    }
    if (changedInfo.containsKey(ChangedInfoKeys.companyInitAgent())) {
      newCompany.setInitAgent(changedInfo.get(ChangedInfoKeys.companyInitAgent()));
      oldValues.put(ChangedInfoKeys.companyInitAgent(), oldCompany.getInitAgent());
    }
    if (changedInfo.containsKey(ChangedInfoKeys.companyRegCountry())) {
      String regCountry = changedInfo.get(ChangedInfoKeys.companyRegCountry());
      newCompany.setRegCountry("null".equals(regCountry) ? null : Integer.parseInt(regCountry));
      oldValues.put(ChangedInfoKeys.companyRegCountry(), oldCompany.getRegCountry());
    }
    if (changedInfo.containsKey(ChangedInfoKeys.companyDesc())) {
      newCompany.setDesc(changedInfo.get(ChangedInfoKeys.companyDesc()));
      oldValues.put(ChangedInfoKeys.companyDesc(), oldCompany.getDesc());
    }

    // 如果有V码,则检查是否有待更新的合同信息
    if (!Strings.isNullOrEmpty(oldCompany.getSupplierCode())) {

      if (changedInfo.containsKey(ChangedInfoKeys.companyGroupName())) {
        newCompany.setGroupName(changedInfo.get(ChangedInfoKeys.companyGroupName()));
        oldValues.put(ChangedInfoKeys.companyGroupName(), oldCompany.getGroupName());
      }

      if (changedInfo.containsKey(ChangedInfoKeys.companyGroupAddr())) {
        newCompany.setGroupAddr(changedInfo.get(ChangedInfoKeys.companyGroupAddr()));
        oldValues.put(ChangedInfoKeys.companyGroupAddr(), oldCompany.getGroupAddr());
      }

      if (changedInfo.containsKey(ChangedInfoKeys.companyRegCapical())) {
        String regCapital = changedInfo.get(ChangedInfoKeys.companyRegCapical());
        newCompany.setRegCapital("null".equals(regCapital) ? null : Long.parseLong(regCapital));
        oldValues.put(ChangedInfoKeys.companyRegCapical(), oldCompany.getRegCapital());
      }

      if (changedInfo.containsKey(ChangedInfoKeys.companyRcCoinType())) {
        String reCoinType = changedInfo.get(ChangedInfoKeys.companyRcCoinType());
        newCompany.setRcCoinType("null".equals(reCoinType) ? null : Integer.parseInt(reCoinType));
        oldValues.put(ChangedInfoKeys.companyRcCoinType(), oldCompany.getRcCoinType());
      }

      if (changedInfo.containsKey(ChangedInfoKeys.companyPersonScale())) {
        newCompany.setPersonScale(changedInfo.get(ChangedInfoKeys.companyPersonScale()));
        oldValues.put(ChangedInfoKeys.companyPersonScale(), oldCompany.getPersonScale());
      }

      if (changedInfo.containsKey(ChangedInfoKeys.companyRegProvince())) {
        String regProvince = changedInfo.get(ChangedInfoKeys.companyRegProvince());
        newCompany.setRegProvince(
            "null".equals(regProvince) ? null : Integer.parseInt(regProvince));
        oldValues.put(ChangedInfoKeys.companyRegProvince(), oldCompany.getRegProvince());
      }

      if (changedInfo.containsKey(ChangedInfoKeys.companyRegCity())) {
        String regCity = changedInfo.get(ChangedInfoKeys.companyRegCity());
        newCompany.setRegCity("null".equals(regCity) ? null : Integer.parseInt(regCity));
        oldValues.put(ChangedInfoKeys.companyRegCity(), oldCompany.getRegCity());
      }

      if (changedInfo.containsKey(ChangedInfoKeys.companyFixedAssets())) {
        String fixedAssets = changedInfo.get(ChangedInfoKeys.companyFixedAssets());
        newCompany.setFixedAssets("null".equals(fixedAssets) ? null : Long.parseLong(fixedAssets));
        oldValues.put(ChangedInfoKeys.companyFixedAssets(), oldCompany.getFixedAssets());
      }

      if (changedInfo.containsKey(ChangedInfoKeys.companyFaCoinType())) {
        String faCoinType = changedInfo.get(ChangedInfoKeys.companyFaCoinType());
        newCompany.setFaCoinType("null".equals(faCoinType) ? null : Integer.parseInt(faCoinType));
        oldValues.put(ChangedInfoKeys.companyFaCoinType(), oldCompany.getFaCoinType());
      }

      if (changedInfo.containsKey(ChangedInfoKeys.companyFoundAt())) {
        String foundAt = changedInfo.get(ChangedInfoKeys.companyFoundAt());
        newCompany.setFoundAt(DateTime.parse(foundAt, FORMATTER).toDate());
        oldValues.put(ChangedInfoKeys.companyFoundAt(), oldCompany.getFoundAt());
      }

      if (changedInfo.containsKey(ChangedInfoKeys.companyOfficialWebSite())) {
        newCompany.setOfficialWebsite(changedInfo.get(ChangedInfoKeys.companyOfficialWebSite()));
        oldValues.put(ChangedInfoKeys.companyOfficialWebSite(), oldCompany.getOfficialWebsite());
      }

      if (changedInfo.containsKey(ChangedInfoKeys.companyNature())) {
        String nature = changedInfo.get(ChangedInfoKeys.companyNature());
        newCompany.setNature("null".equals(nature) ? null : Integer.parseInt(nature));
        oldValues.put(ChangedInfoKeys.companyNature(), oldCompany.getNature());
      }

      if (changedInfo.containsKey(ChangedInfoKeys.companyWorldTop())) {
        String worldTop = changedInfo.get(ChangedInfoKeys.companyWorldTop());
        newCompany.setWorldTop("null".equals(worldTop) ? null : Integer.parseInt(worldTop));
        oldValues.put(ChangedInfoKeys.companyWorldTop(), oldCompany.getWorldTop());
      }

      if (changedInfo.containsKey(ChangedInfoKeys.companyListedStatus())) {
        String listedStatus = changedInfo.get(ChangedInfoKeys.companyListedStatus());
        newCompany.setListedStatus(
            "null".equals(listedStatus) ? null : Integer.parseInt(listedStatus));
        oldValues.put(ChangedInfoKeys.companyListedStatus(), oldCompany.getListedStatus());
      }

      if (changedInfo.containsKey(ChangedInfoKeys.companyListedRegion())) {
        newCompany.setListedRegion(changedInfo.get(ChangedInfoKeys.companyListedRegion()));
        oldValues.put(ChangedInfoKeys.companyListedRegion(), oldCompany.getListedRegion());
      }

      if (changedInfo.containsKey(ChangedInfoKeys.companyTicker())) {
        newCompany.setTicker(changedInfo.get(ChangedInfoKeys.companyTicker()));
        oldValues.put(ChangedInfoKeys.companyTicker(), oldCompany.getTicker());
      }
    }

    companyDto.setCompany(newCompany);

    if (changedInfo.containsKey(ChangedInfoKeys.companyMainBusiness())) {
      String mainBusinessesJson = changedInfo.get(ChangedInfoKeys.companyMainBusiness());
      JavaType javaType =
          JsonMapper.JSON_NON_EMPTY_MAPPER.createCollectionType(
              List.class, CompanyMainBusiness.class);
      List<CompanyMainBusiness> updatedMainBusinesses =
          JsonMapper.JSON_NON_EMPTY_MAPPER.fromJson(mainBusinessesJson, javaType);
      companyDto.setCompanyMainBusinesses(updatedMainBusinesses);

      oldValues.put(ChangedInfoKeys.companyMainBusiness(), oldMainBusinesses);
    } else {
      companyDto.setCompanyMainBusinesses(oldMainBusinesses);
    }

    if (changedInfo.containsKey(ChangedInfoKeys.companySupplyPark())) {
      String supplyParkJson = changedInfo.get(ChangedInfoKeys.companySupplyPark());
      JavaType javaType =
          JsonMapper.JSON_NON_EMPTY_MAPPER.createCollectionType(
              List.class, CompanySupplyPark.class);
      List<CompanySupplyPark> updatedSupplyParks =
          JsonMapper.JSON_NON_EMPTY_MAPPER.fromJson(supplyParkJson, javaType);
      companyDto.setCompanySupplyParks(updatedSupplyParks);

      oldValues.put(ChangedInfoKeys.companySupplyPark(), oldSupplyParks);
    } else {
      companyDto.setCompanySupplyParks(oldSupplyParks);
    }

    supplierUpdatedInfoDto.setSupplierInfo(companyDto);
    supplierUpdatedInfoDto.setOldValues(oldValues);
    return supplierUpdatedInfoDto;
  }