/** 检查营业执照修改情况 */
  private void checkBusinessLicense(
      Map<String, String> changedInfo, PaperworkDto updatedPaperwork, PaperworkDto oldPaperwork) {

    if (!Objects.equal(updatedPaperwork.getBusinessLicense(), oldPaperwork.getBusinessLicense())) {
      changedInfo.put(
          ChangedInfoKeys.companyBusinessLicense(), updatedPaperwork.getBusinessLicense());
    }
    if (!Objects.equal(
        updatedPaperwork.getBusinessLicenseId(), oldPaperwork.getBusinessLicenseId())) {
      changedInfo.put(
          ChangedInfoKeys.companyBusinessLicenseId(), updatedPaperwork.getBusinessLicenseId());
    }

    DateTime updatedBlDate = new DateTime(updatedPaperwork.getBlDate());
    if (oldPaperwork.getBlDate() == null) {
      changedInfo.put(
          ChangedInfoKeys.companyBusinessLicenseDate(), updatedBlDate.toString(FORMATTER));
    } else {
      DateTime oldBlDate = new DateTime(oldPaperwork.getBlDate());
      if (!updatedBlDate.isEqual(oldBlDate)) {
        changedInfo.put(
            ChangedInfoKeys.companyBusinessLicenseDate(), updatedBlDate.toString(FORMATTER));
      }
    }
  }
  /** 检查组织机构修改情况 */
  private void checkOrgCert(
      Map<String, String> changedInfo, PaperworkDto updatedPaperwork, PaperworkDto oldPaperwork) {

    if (!Objects.equal(updatedPaperwork.getOrgCert(), oldPaperwork.getOrgCert())) {
      changedInfo.put(ChangedInfoKeys.companyOrgCert(), updatedPaperwork.getOrgCert());
    }
    if (!Objects.equal(updatedPaperwork.getOrgCertId(), oldPaperwork.getOrgCertId())) {
      changedInfo.put(ChangedInfoKeys.companyOrgCertId(), updatedPaperwork.getOrgCertId());
    }

    DateTime updatedOcDate = new DateTime(updatedPaperwork.getOcDate());
    if (oldPaperwork.getOcDate() == null) {
      changedInfo.put(ChangedInfoKeys.companyOrgCertDate(), updatedOcDate.toString(FORMATTER));
    } else {
      DateTime oldOcDate = new DateTime(oldPaperwork.getOcDate());
      if (!updatedOcDate.isEqual(oldOcDate)) {
        changedInfo.put(ChangedInfoKeys.companyOrgCertDate(), updatedOcDate.toString(FORMATTER));
      }
    }
  }
  /** 检查税务证修改情况 */
  private void checkTaxNo(
      Map<String, String> changedInfo, PaperworkDto updatedPaperwork, PaperworkDto oldPaperwork) {

    if (!Objects.equal(updatedPaperwork.getTaxNo(), oldPaperwork.getTaxNo())) {
      changedInfo.put(ChangedInfoKeys.companyTaxNo(), updatedPaperwork.getTaxNo());
    }
    if (!Objects.equal(updatedPaperwork.getTaxNoId(), oldPaperwork.getTaxNoId())) {
      changedInfo.put(ChangedInfoKeys.companyTaxNoId(), updatedPaperwork.getTaxNoId());
    }
  }
  @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;
  }