コード例 #1
0
  @Override
  public SupplierInfoChangedDto financeChanged(
      Long userId, Finance updatedFinance, Finance oldFinance) {
    SupplierInfoChangedDto supplierInfoChangedDto = new SupplierInfoChangedDto();

    Finance newFinance = getNewFinance(userId, oldFinance).getSupplierInfo();

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

    if (!Objects.equal(updatedFinance.getCountry(), newFinance.getCountry())) {
      changedInfo.put(
          ChangedInfoKeys.financeCountry(), String.valueOf(updatedFinance.getCountry()));
      updatedFinance.setCountry(null);
    }
    if (!Objects.equal(updatedFinance.getBankAccount(), newFinance.getBankAccount())) {
      changedInfo.put(ChangedInfoKeys.financeBankAccount(), updatedFinance.getBankAccount());
      updatedFinance.setBankAccount(null);
    }
    if (!Objects.equal(updatedFinance.getBankCode(), newFinance.getBankCode())) {
      changedInfo.put(ChangedInfoKeys.financeBankCode(), updatedFinance.getBankCode());
      updatedFinance.setBankCode(null);
    }
    if (!Objects.equal(updatedFinance.getCoinType(), newFinance.getCoinType())) {
      changedInfo.put(
          ChangedInfoKeys.financeCoinType(), String.valueOf(updatedFinance.getCoinType()));
      updatedFinance.setCoinType(null);
    }
    if (!Objects.equal(updatedFinance.getOpenLicense(), newFinance.getOpenLicense())) {
      changedInfo.put(ChangedInfoKeys.financeOpenLicense(), updatedFinance.getOpenLicense());
      updatedFinance.setOpenLicense(null);
    }
    if (!Objects.equal(updatedFinance.getRecentFinance(), newFinance.getRecentFinance())) {
      changedInfo.put(ChangedInfoKeys.financeRecentFinance(), updatedFinance.getRecentFinance());
      updatedFinance.setRecentFinance(null);
    }
    if (!Objects.equal(updatedFinance.getOpeningBank(), newFinance.getOpeningBank())) {
      changedInfo.put(ChangedInfoKeys.financeOpeningBank(), updatedFinance.getOpeningBank());
      updatedFinance.setOpeningBank(null);
    }

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

    return supplierInfoChangedDto;
  }
コード例 #2
0
  @Override
  public SupplierUpdatedInfoDto<Finance> getNewFinance(Long userId, Finance oldFinance) {

    SupplierUpdatedInfoDto<Finance> supplierUpdatedInfoDto = new SupplierUpdatedInfoDto<Finance>();
    Map<String, Object> oldValues = Maps.newHashMap();

    boolean financeChanged =
        supplierChangedInfoRedisDao.tabInfoChanged(userId, ChangedInfoKeys.financeTab());
    if (!financeChanged) {
      supplierUpdatedInfoDto.setSupplierInfo(oldFinance);
      supplierUpdatedInfoDto.setOldValues(oldValues);
      return supplierUpdatedInfoDto;
    }

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

    Finance newFinance = new Finance();
    BeanMapper.copy(oldFinance, newFinance);

    if (changedInfo.containsKey(ChangedInfoKeys.financeOpeningBank())) {
      newFinance.setOpeningBank(changedInfo.get(ChangedInfoKeys.financeOpeningBank()));
      oldValues.put(ChangedInfoKeys.financeOpeningBank(), oldFinance.getOpeningBank());
    }
    if (changedInfo.containsKey(ChangedInfoKeys.financeOpenLicense())) {
      newFinance.setOpenLicense(changedInfo.get(ChangedInfoKeys.financeOpenLicense()));
      oldValues.put(ChangedInfoKeys.financeOpenLicense(), oldFinance.getOpenLicense());
    }
    if (changedInfo.containsKey(ChangedInfoKeys.financeRecentFinance())) {
      newFinance.setRecentFinance(changedInfo.get(ChangedInfoKeys.financeRecentFinance()));
      oldValues.put(ChangedInfoKeys.financeRecentFinance(), oldFinance.getRecentFinance());
    }
    if (changedInfo.containsKey(ChangedInfoKeys.financeCoinType())) {
      String coinType = changedInfo.get(ChangedInfoKeys.financeCoinType());
      newFinance.setCoinType("null".equals(coinType) ? null : Integer.parseInt(coinType));
      oldValues.put(ChangedInfoKeys.financeCoinType(), oldFinance.getCoinType());
    }
    if (changedInfo.containsKey(ChangedInfoKeys.financeBankCode())) {
      newFinance.setBankCode(changedInfo.get(ChangedInfoKeys.financeBankCode()));
      oldValues.put(ChangedInfoKeys.financeBankCode(), oldFinance.getBankCode());
    }
    if (changedInfo.containsKey(ChangedInfoKeys.financeBankAccount())) {
      newFinance.setBankAccount(changedInfo.get(ChangedInfoKeys.financeBankAccount()));
      oldValues.put(ChangedInfoKeys.financeBankAccount(), oldFinance.getBankAccount());
    }
    if (changedInfo.containsKey(ChangedInfoKeys.financeCountry())) {
      String country = changedInfo.get(ChangedInfoKeys.financeCountry());
      newFinance.setCountry("null".equals(country) ? null : Integer.parseInt(country));
      oldValues.put(ChangedInfoKeys.financeCountry(), oldFinance.getCountry());
    }

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