Ejemplo n.º 1
0
  @Override
  public Response<Boolean> updateTagsByCompany(Long userId, Company company) {

    Response<Boolean> result = new Response<Boolean>();

    if (userId == null) {
      log.error("user id can not be null");
      result.setError("user.id.not.null.fail");
      return result;
    }

    if (company == null) {
      log.error("company can not be null");
      result.setError("company.not.null.fail");
      return result;
    }

    try {

      User user = userDao.findById(userId);
      if (user == null) {
        log.error("user(user id={}) not found", userId);
        result.setError("user.not.found");
        return result;
      }

      List<String> tags = user.buildTags();

      if (Objects.equal(company.getWorldTop(), Company.WorldTop.IS_WORLD_TOP_500.value())) {
        add(tags, User.SupplierTag.WORLD_TOP_SUPPLIER.toString());
      } else if (Objects.equal(company.getWorldTop(), Company.WorldTop.NO_WORLD_TOP_500.value())) {
        remove(tags, User.SupplierTag.WORLD_TOP_SUPPLIER.toString());
      }

      if (!Strings.isNullOrEmpty(company.getSupplierCode())) {
        add(tags, User.SupplierTag.IN_SUPPLIER.toString());
      }

      user.setTagsFromList(tags);
      userDao.update(user);

      result.setResult(Boolean.TRUE);

    } catch (Exception e) {
      log.error(
          "fail to update tag where user id={},company={},cause:{}",
          userId,
          company,
          Throwables.getStackTraceAsString(e));
      result.setError("add.tag.fail");
    }

    return result;
  }
  @Override
  public SupplierInfoChangedDto paperworkChanged(
      Long userId, PaperworkDto updatedPaperwork, Company oldPaperwork) {
    SupplierInfoChangedDto supplierInfoChangedDto = new SupplierInfoChangedDto();

    Map<String, String> changedInfo = Maps.newHashMap();

    int type = CountryCertificate.check(oldPaperwork.getRegCountry());

    PaperworkDto newPaperworkDto = getNewPaperwork(userId, oldPaperwork).getSupplierInfo();

    switch (type) {
      case CountryCertificate.NO_CERTIFICATE:
        supplierInfoChangedDto.setChanged(false);
        return supplierInfoChangedDto;
      case CountryCertificate.ONLY_NEED_BUSINESS_LICENSE:
        checkBusinessLicense(changedInfo, updatedPaperwork, newPaperworkDto);
        break;
      case CountryCertificate.ONLY_NEED_BUSINESS_LICENSE_AND_TAX_NO:
        checkBusinessLicense(changedInfo, updatedPaperwork, newPaperworkDto);
        checkTaxNo(changedInfo, updatedPaperwork, newPaperworkDto);
        break;
      default:
        checkBusinessLicense(changedInfo, updatedPaperwork, newPaperworkDto);
        checkTaxNo(changedInfo, updatedPaperwork, newPaperworkDto);
        checkOrgCert(changedInfo, updatedPaperwork, newPaperworkDto);
    }

    if (!changedInfo.isEmpty()) {
      supplierInfoChangedDto.setChanged(true);
      supplierInfoChangedDto.setChangedInfo(changedInfo);
    }

    return supplierInfoChangedDto;
  }
  public SupplierInfoChangedDto contactInfoChanged(
      Long userId, ContactInfo updatedContactInfo, ContactInfo oldContactInfo) {
    SupplierInfoChangedDto supplierInfoChangedDto = new SupplierInfoChangedDto();

    ContactInfo newContactInfo = getNewContactInfo(userId, oldContactInfo).getSupplierInfo();

    Map<String, String> changedInfo = Maps.newHashMap();

    if (!Objects.equal(updatedContactInfo.getName(), newContactInfo.getName())) {
      changedInfo.put(ChangedInfoKeys.contactInfoName(), updatedContactInfo.getName());
      updatedContactInfo.setName(null);
    }

    if (!Objects.equal(updatedContactInfo.getEmail(), newContactInfo.getEmail())) {
      changedInfo.put(ChangedInfoKeys.contactInfoEmail(), updatedContactInfo.getEmail());
      updatedContactInfo.setEmail(null);
    }

    if (!Objects.equal(updatedContactInfo.getMobile(), newContactInfo.getMobile())) {
      changedInfo.put(ChangedInfoKeys.contactInfoMobile(), updatedContactInfo.getMobile());
      updatedContactInfo.setMobile(null);
    }

    Company company = companyDao.findByUserId(userId);
    if (!Strings.isNullOrEmpty(company.getSupplierCode())) {
      if (!Objects.equal(updatedContactInfo.getOfficePhone(), newContactInfo.getOfficePhone())) {
        changedInfo.put(ChangedInfoKeys.contactInfoPhone(), updatedContactInfo.getOfficePhone());
        updatedContactInfo.setOfficePhone(null);
      }
    }

    if (!changedInfo.isEmpty()) {
      supplierInfoChangedDto.setChanged(true);
      supplierInfoChangedDto.setChangedInfo(changedInfo);
    }
    return supplierInfoChangedDto;
  }
  @Override
  public SupplierInfoChangedDto baseCompanyChanged(
      Long userId,
      CompanyDto updatedCompanyDto,
      Company oldCompany,
      List<CompanyMainBusiness> oldMainBusinesses,
      List<CompanySupplyPark> oldSupplyParks) {
    SupplierInfoChangedDto supplierInfoChangedDto = new SupplierInfoChangedDto();

    Company updatedCompany = updatedCompanyDto.getCompany();
    List<CompanyMainBusiness> updatedMainBusinesses = updatedCompanyDto.getCompanyMainBusinesses();
    List<CompanySupplyPark> updatedSupplyParks = updatedCompanyDto.getCompanySupplyParks();

    // 取出新的信息
    CompanyDto newCompanyDto =
        getNewBaseCompany(userId, oldCompany, oldMainBusinesses, oldSupplyParks).getSupplierInfo();
    Company newCompany = newCompanyDto.getCompany();
    List<CompanyMainBusiness> newMainBusinesses = newCompanyDto.getCompanyMainBusinesses();
    List<CompanySupplyPark> newSupplyParks = newCompanyDto.getCompanySupplyParks();

    Map<String, String> changedInfo = Maps.newHashMap();

    if (!Objects.equal(updatedCompany.getCorporation(), newCompany.getCorporation())) {
      changedInfo.put(ChangedInfoKeys.companyCorporation(), updatedCompany.getCorporation());
      updatedCompany.setCorporation(null);
    }

    if (!Objects.equal(updatedCompany.getInitAgent(), newCompany.getInitAgent())) {
      changedInfo.put(ChangedInfoKeys.companyInitAgent(), updatedCompany.getInitAgent());
      updatedCompany.setInitAgent(null);
    }

    if (!Objects.equal(updatedCompany.getDesc(), newCompany.getDesc())) {
      changedInfo.put(ChangedInfoKeys.companyDesc(), updatedCompany.getDesc());
      updatedCompany.setDesc(null);
    }

    if (!Objects.equal(updatedCompany.getRegCountry(), newCompany.getRegCountry())) {
      changedInfo.put(
          ChangedInfoKeys.companyRegCountry(), String.valueOf(updatedCompany.getRegCountry()));
      updatedCompany.setRegCountry(null);
    }

    //        if (!Objects.equal(company.getCustomers(), newCompany.getCustomers())) {
    //            changedInfo.put("", newCompany.getCustomers());
    //        }
    //
    if (!Objects.equal(updatedCompany.getProductLine(), newCompany.getProductLine())) {
      changedInfo.put(ChangedInfoKeys.companyProductLine(), updatedCompany.getProductLine());
    }

    if (mainBusinessChanged(updatedMainBusinesses, newMainBusinesses)) {
      changedInfo.put(
          ChangedInfoKeys.companyMainBusiness(),
          JsonMapper.nonEmptyMapper().toJson(updatedMainBusinesses));
    }

    if (supplyParkChanged(updatedSupplyParks, newSupplyParks)) {
      changedInfo.put(
          ChangedInfoKeys.companySupplyPark(),
          JsonMapper.nonEmptyMapper().toJson(updatedSupplyParks));
    }

    // 如果有V码,则继续检查合同信息
    if (!Strings.isNullOrEmpty(newCompany.getSupplierCode())) {

      if (!Objects.equal(updatedCompany.getGroupName(), newCompany.getGroupName())) {
        changedInfo.put(ChangedInfoKeys.companyGroupName(), updatedCompany.getGroupName());
        updatedCompany.setGroupName(null);
      }
      if (!Objects.equal(updatedCompany.getGroupAddr(), newCompany.getGroupAddr())) {
        changedInfo.put(ChangedInfoKeys.companyGroupAddr(), updatedCompany.getGroupAddr());
        updatedCompany.setGroupAddr(null);
      }
      if (!Objects.equal(updatedCompany.getRegCapital(), newCompany.getRegCapital())) {
        changedInfo.put(
            ChangedInfoKeys.companyRegCapical(), String.valueOf(updatedCompany.getRegCapital()));
        updatedCompany.setRegCapital(null);
      }
      if (!Objects.equal(updatedCompany.getRcCoinType(), newCompany.getRcCoinType())) {
        changedInfo.put(
            ChangedInfoKeys.companyRcCoinType(), String.valueOf(updatedCompany.getRcCoinType()));
        updatedCompany.setRcCoinType(null);
      }
      if (!Objects.equal(updatedCompany.getPersonScale(), newCompany.getPersonScale())) {
        changedInfo.put(ChangedInfoKeys.companyPersonScale(), updatedCompany.getPersonScale());
        updatedCompany.setPersonScale(null);
      }
      if (!Objects.equal(updatedCompany.getRegProvince(), newCompany.getRegProvince())) {
        changedInfo.put(
            ChangedInfoKeys.companyRegProvince(), String.valueOf(updatedCompany.getRegProvince()));
        updatedCompany.setRegProvince(null);
      }
      if (!Objects.equal(updatedCompany.getRegCity(), newCompany.getRegCity())) {
        changedInfo.put(
            ChangedInfoKeys.companyRegCity(), String.valueOf(updatedCompany.getRegCity()));
        updatedCompany.setRegCity(null);
      }
      if (!Objects.equal(updatedCompany.getFixedAssets(), newCompany.getFixedAssets())) {
        changedInfo.put(
            ChangedInfoKeys.companyFixedAssets(), String.valueOf(updatedCompany.getFixedAssets()));
        updatedCompany.setFixedAssets(null);
      }
      if (!Objects.equal(updatedCompany.getFaCoinType(), newCompany.getFaCoinType())) {
        changedInfo.put(
            ChangedInfoKeys.companyFaCoinType(), String.valueOf(updatedCompany.getFaCoinType()));
        updatedCompany.setFaCoinType(null);
      }

      Date updatedFoundAt = updatedCompany.getFoundAt();
      Date oldFoundAt = newCompany.getFoundAt();
      if (updatedFoundAt != null) {
        DateTime updated = new DateTime(updatedFoundAt);
        if (oldFoundAt == null) {
          changedInfo.put(ChangedInfoKeys.companyFoundAt(), updated.toString(FORMATTER));
          updatedCompany.setFoundAt(null);
        } else {
          DateTime old = new DateTime(oldFoundAt);
          if (!updated.equals(old)) {
            changedInfo.put(ChangedInfoKeys.companyFoundAt(), updated.toString(FORMATTER));
            updatedCompany.setFoundAt(null);
          }
        }
      }

      if (!Objects.equal(updatedCompany.getOfficialWebsite(), newCompany.getOfficialWebsite())) {
        changedInfo.put(
            ChangedInfoKeys.companyOfficialWebSite(), updatedCompany.getOfficialWebsite());
        updatedCompany.setOfficialWebsite(null);
      }
      if (!Objects.equal(updatedCompany.getNature(), newCompany.getNature())) {
        changedInfo.put(
            ChangedInfoKeys.companyNature(), String.valueOf(updatedCompany.getNature()));
        updatedCompany.setNature(null);
      }
      if (!Objects.equal(updatedCompany.getWorldTop(), newCompany.getWorldTop())) {
        changedInfo.put(
            ChangedInfoKeys.companyWorldTop(), String.valueOf(updatedCompany.getWorldTop()));
        updatedCompany.setWorldTop(null);
      }
      if (!Objects.equal(updatedCompany.getListedStatus(), newCompany.getListedStatus())) {
        changedInfo.put(
            ChangedInfoKeys.companyListedStatus(),
            String.valueOf(updatedCompany.getListedStatus()));
        updatedCompany.setListedStatus(null);
      }
      if (!Objects.equal(updatedCompany.getListedRegion(), newCompany.getListedRegion())) {
        changedInfo.put(ChangedInfoKeys.companyListedRegion(), updatedCompany.getListedRegion());
        updatedCompany.setListedRegion(null);
      }
      if (!Objects.equal(updatedCompany.getTicker(), newCompany.getTicker())) {
        changedInfo.put(ChangedInfoKeys.companyTicker(), updatedCompany.getTicker());
        updatedCompany.setTicker(null);
      }
    }

    if (!changedInfo.isEmpty()) {
      supplierInfoChangedDto.setChanged(true);
      supplierInfoChangedDto.setChangedInfo(changedInfo);
    }

    return supplierInfoChangedDto;
  }
  @Override
  public SupplierUpdatedInfoDto<PaperworkDto> getNewPaperwork(Long userId, Company oldPaperwork) {
    SupplierUpdatedInfoDto<PaperworkDto> supplierUpdatedInfoDto =
        new SupplierUpdatedInfoDto<PaperworkDto>();
    PaperworkDto paperworkDto = new PaperworkDto();
    Map<String, Object> oldValues = Maps.newHashMap();

    BeanMapper.copy(oldPaperwork, paperworkDto);

    boolean paperworkChanged =
        supplierChangedInfoRedisDao.tabInfoChanged(userId, ChangedInfoKeys.paperworkTab());
    if (!paperworkChanged) {
      supplierUpdatedInfoDto.setSupplierInfo(paperworkDto);
      supplierUpdatedInfoDto.setOldValues(oldValues);
      return supplierUpdatedInfoDto;
    }

    Map<String, String> changedInfo = supplierChangedInfoRedisDao.getChangedInfos(userId);

    if (changedInfo.containsKey(ChangedInfoKeys.companyBusinessLicense())) {
      paperworkDto.setBusinessLicense(changedInfo.get(ChangedInfoKeys.companyBusinessLicense()));
      oldValues.put(ChangedInfoKeys.companyBusinessLicense(), oldPaperwork.getBusinessLicense());
    }
    if (changedInfo.containsKey(ChangedInfoKeys.companyBusinessLicenseId())) {
      paperworkDto.setBusinessLicenseId(
          changedInfo.get(ChangedInfoKeys.companyBusinessLicenseId()));
      oldValues.put(
          ChangedInfoKeys.companyBusinessLicenseId(), oldPaperwork.getBusinessLicenseId());
    }
    if (changedInfo.containsKey(ChangedInfoKeys.companyBusinessLicenseDate())) {
      String blDate = changedInfo.get(ChangedInfoKeys.companyBusinessLicenseDate());
      paperworkDto.setBlDate(DateTime.parse(blDate, FORMATTER).toDate());
      oldValues.put(ChangedInfoKeys.companyBusinessLicenseDate(), oldPaperwork.getBlDate());
    }

    if (changedInfo.containsKey(ChangedInfoKeys.companyTaxNo())) {
      paperworkDto.setTaxNo(changedInfo.get(ChangedInfoKeys.companyTaxNo()));
      oldValues.put(ChangedInfoKeys.companyTaxNo(), oldPaperwork.getTaxNo());
    }
    if (changedInfo.containsKey(ChangedInfoKeys.companyTaxNoId())) {
      paperworkDto.setTaxNoId(changedInfo.get(ChangedInfoKeys.companyTaxNoId()));
      oldValues.put(ChangedInfoKeys.companyTaxNoId(), oldPaperwork.getTaxNoId());
    }

    if (changedInfo.containsKey(ChangedInfoKeys.companyOrgCert())) {
      paperworkDto.setOrgCert(changedInfo.get(ChangedInfoKeys.companyOrgCert()));
      oldValues.put(ChangedInfoKeys.companyOrgCert(), oldPaperwork.getOrgCert());
    }
    if (changedInfo.containsKey(ChangedInfoKeys.companyOrgCertId())) {
      paperworkDto.setOrgCertId(changedInfo.get(ChangedInfoKeys.companyOrgCertId()));
      oldValues.put(ChangedInfoKeys.companyOrgCertId(), oldPaperwork.getOrgCertId());
    }
    if (changedInfo.containsKey(ChangedInfoKeys.companyOrgCertDate())) {
      String ocDate = changedInfo.get(ChangedInfoKeys.companyOrgCertDate());
      paperworkDto.setOcDate(DateTime.parse(ocDate, FORMATTER).toDate());
      oldValues.put(ChangedInfoKeys.companyOrgCertDate(), oldPaperwork.getOcDate());
    }

    supplierUpdatedInfoDto.setSupplierInfo(paperworkDto);
    supplierUpdatedInfoDto.setOldValues(oldValues);
    return supplierUpdatedInfoDto;
  }
  @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;
  }