コード例 #1
0
  @Override
  public SupplierUpdatedInfoDto<CompanyExtraQuality> getNewCompanyExtraQuality(
      Long userId, CompanyExtraQuality oldCompanyExtraQuality) {

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

    boolean qualityChanged =
        supplierChangedInfoRedisDao.tabInfoChanged(userId, ChangedInfoKeys.qualityTab());
    if (!qualityChanged) {
      supplierUpdatedInfoDto.setSupplierInfo(oldCompanyExtraQuality);
      supplierUpdatedInfoDto.setOldValues(oldValues);
      return supplierUpdatedInfoDto;
    }

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

    CompanyExtraQuality newCompanyExtraQuality = new CompanyExtraQuality();
    BeanMapper.copy(oldCompanyExtraQuality, newCompanyExtraQuality);

    if (changedInfo.containsKey(ChangedInfoKeys.qualityRohsId())) {
      newCompanyExtraQuality.setRohsId(changedInfo.get(ChangedInfoKeys.qualityRohsId()));
      oldValues.put(ChangedInfoKeys.qualityRohsId(), oldCompanyExtraQuality.getRohsId());
    }
    if (changedInfo.containsKey(ChangedInfoKeys.qualityRohsAttachUrl())) {
      newCompanyExtraQuality.setRohsAttachUrl(
          changedInfo.get(ChangedInfoKeys.qualityRohsAttachUrl()));
      oldValues.put(
          ChangedInfoKeys.qualityRohsAttachUrl(), oldCompanyExtraQuality.getRohsAttachUrl());
    }
    if (changedInfo.containsKey(ChangedInfoKeys.qualityRohsValidDate())) {
      String rohsValidDate = changedInfo.get(ChangedInfoKeys.qualityRohsValidDate());
      newCompanyExtraQuality.setRohsValidDate(DateTime.parse(rohsValidDate, FORMATTER).toDate());
      oldValues.put(
          ChangedInfoKeys.qualityRohsValidDate(), oldCompanyExtraQuality.getRohsValidDate());
    }

    if (changedInfo.containsKey(ChangedInfoKeys.qualityISO9001Id())) {
      newCompanyExtraQuality.setIso9001Id(changedInfo.get(ChangedInfoKeys.qualityISO9001Id()));
      oldValues.put(ChangedInfoKeys.qualityISO9001Id(), oldCompanyExtraQuality.getIso9001Id());
    }
    if (changedInfo.containsKey(ChangedInfoKeys.qualityISO9001AttachUrl())) {
      newCompanyExtraQuality.setIso9001AttachUrl(
          changedInfo.get(ChangedInfoKeys.qualityISO9001AttachUrl()));
      oldValues.put(
          ChangedInfoKeys.qualityISO9001AttachUrl(), oldCompanyExtraQuality.getIso9001AttachUrl());
    }
    if (changedInfo.containsKey(ChangedInfoKeys.qualityISO9001ValidDate())) {
      String iso900ValidDate = changedInfo.get(ChangedInfoKeys.qualityISO9001ValidDate());
      newCompanyExtraQuality.setIso9001ValidDate(
          DateTime.parse(iso900ValidDate, FORMATTER).toDate());
      oldValues.put(
          ChangedInfoKeys.qualityISO9001ValidDate(), oldCompanyExtraQuality.getIso9001ValidDate());
    }

    if (changedInfo.containsKey(ChangedInfoKeys.qualityISO14001Id())) {
      newCompanyExtraQuality.setIso14001Id(changedInfo.get(ChangedInfoKeys.qualityISO14001Id()));
      oldValues.put(ChangedInfoKeys.qualityISO14001Id(), oldCompanyExtraQuality.getIso14001Id());
    }
    if (changedInfo.containsKey(ChangedInfoKeys.qualityISO14001AttachUrl())) {
      newCompanyExtraQuality.setIso14001AttachUrl(
          changedInfo.get(ChangedInfoKeys.qualityISO14001AttachUrl()));
      oldValues.put(
          ChangedInfoKeys.qualityISO14001AttachUrl(),
          oldCompanyExtraQuality.getIso14001AttachUrl());
    }
    if (changedInfo.containsKey(ChangedInfoKeys.qualityISO14001ValidDate())) {
      String iso1400ValidDate = changedInfo.get(ChangedInfoKeys.qualityISO14001ValidDate());
      newCompanyExtraQuality.setIso14001ValidDate(
          DateTime.parse(iso1400ValidDate, FORMATTER).toDate());
      oldValues.put(
          ChangedInfoKeys.qualityISO14001ValidDate(),
          oldCompanyExtraQuality.getIso14001ValidDate());
    }

    if (changedInfo.containsKey(ChangedInfoKeys.qualityTS16949Id())) {
      newCompanyExtraQuality.setTs16949Id(changedInfo.get(ChangedInfoKeys.qualityTS16949Id()));
      oldValues.put(ChangedInfoKeys.qualityTS16949Id(), oldCompanyExtraQuality.getTs16949Id());
    }
    if (changedInfo.containsKey(ChangedInfoKeys.qualityTS16949AttachUrl())) {
      newCompanyExtraQuality.setTs16949AttachUrl(
          changedInfo.get(ChangedInfoKeys.qualityTS16949AttachUrl()));
      oldValues.put(
          ChangedInfoKeys.qualityTS16949AttachUrl(), oldCompanyExtraQuality.getTs16949AttachUrl());
    }
    if (changedInfo.containsKey(ChangedInfoKeys.qualityTS16949ValidDate())) {
      String ts16949ValidDate = changedInfo.get(ChangedInfoKeys.qualityTS16949ValidDate());
      newCompanyExtraQuality.setTs16949ValidDate(
          DateTime.parse(ts16949ValidDate, FORMATTER).toDate());
      oldValues.put(
          ChangedInfoKeys.qualityTS16949ValidDate(), oldCompanyExtraQuality.getTs16949ValidDate());
    }

    supplierUpdatedInfoDto.setSupplierInfo(newCompanyExtraQuality);
    supplierUpdatedInfoDto.setOldValues(oldValues);
    return supplierUpdatedInfoDto;
  }
コード例 #2
0
  @Override
  public SupplierInfoChangedDto qualityChanged(
      Long userId, CompanyExtraQuality updatedQuality, CompanyExtraQuality oldQuality) {
    SupplierInfoChangedDto supplierInfoChangedDto = new SupplierInfoChangedDto();

    CompanyExtraQuality newQuality =
        getNewCompanyExtraQuality(userId, oldQuality).getSupplierInfo();

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

    if (!Objects.equal(updatedQuality.getRohsId(), newQuality.getRohsId())) {
      changedInfo.put(ChangedInfoKeys.qualityRohsId(), updatedQuality.getRohsId());
      updatedQuality.setRohsId(null);
    }
    if (!Objects.equal(updatedQuality.getRohsAttachUrl(), newQuality.getRohsAttachUrl())) {
      changedInfo.put(ChangedInfoKeys.qualityRohsAttachUrl(), updatedQuality.getRohsAttachUrl());
      updatedQuality.setRohsAttachUrl(null);
    }

    if (updatedQuality.getRohsValidDate() != null) {
      DateTime updatedRohsValidDate = new DateTime(updatedQuality.getRohsValidDate());
      if (newQuality.getRohsValidDate() == null) {
        changedInfo.put(
            ChangedInfoKeys.qualityRohsValidDate(), updatedRohsValidDate.toString(FORMATTER));
        updatedQuality.setRohsValidDate(null);
      } else {
        DateTime oldRohsValidDate = new DateTime(newQuality.getRohsValidDate());
        if (!updatedRohsValidDate.equals(oldRohsValidDate)) {
          changedInfo.put(
              ChangedInfoKeys.qualityRohsValidDate(), updatedRohsValidDate.toString(FORMATTER));
          updatedQuality.setRohsValidDate(null);
        }
      }
    }

    if (!Objects.equal(updatedQuality.getIso9001Id(), newQuality.getIso9001Id())) {
      changedInfo.put(ChangedInfoKeys.qualityISO9001Id(), updatedQuality.getIso9001Id());
      updatedQuality.setIso9001Id(null);
    }
    if (!Objects.equal(updatedQuality.getIso9001AttachUrl(), newQuality.getIso9001AttachUrl())) {
      changedInfo.put(
          ChangedInfoKeys.qualityISO9001AttachUrl(), updatedQuality.getIso9001AttachUrl());
      updatedQuality.setIso9001AttachUrl(null);
    }

    if (updatedQuality.getIso9001ValidDate() != null) {
      DateTime updatedIso9001ValidDate = new DateTime(updatedQuality.getIso9001ValidDate());
      if (newQuality.getIso9001ValidDate() == null) {
        changedInfo.put(
            ChangedInfoKeys.qualityISO9001ValidDate(), updatedIso9001ValidDate.toString(FORMATTER));
        updatedQuality.setIso9001ValidDate(null);
      } else {
        DateTime oldIso9001ValidDate = new DateTime(newQuality.getIso9001ValidDate());
        if (!updatedIso9001ValidDate.equals(oldIso9001ValidDate)) {
          changedInfo.put(
              ChangedInfoKeys.qualityISO9001ValidDate(),
              updatedIso9001ValidDate.toString(FORMATTER));
          updatedQuality.setIso9001ValidDate(null);
        }
      }
    }

    if (!Objects.equal(updatedQuality.getIso14001Id(), newQuality.getIso14001Id())) {
      changedInfo.put(ChangedInfoKeys.qualityISO14001Id(), updatedQuality.getIso14001Id());
      updatedQuality.setIso14001Id(null);
    }
    if (!Objects.equal(updatedQuality.getIso14001AttachUrl(), newQuality.getIso14001AttachUrl())) {
      changedInfo.put(
          ChangedInfoKeys.qualityISO14001AttachUrl(), updatedQuality.getIso14001AttachUrl());
      updatedQuality.setIso14001AttachUrl(null);
    }

    if (updatedQuality.getIso14001ValidDate() != null) {
      DateTime updatedIso14001ValidDate = new DateTime(updatedQuality.getIso14001ValidDate());
      if (newQuality.getIso14001ValidDate() == null) {
        changedInfo.put(
            ChangedInfoKeys.qualityISO14001ValidDate(),
            updatedIso14001ValidDate.toString(FORMATTER));
        updatedQuality.setIso14001ValidDate(null);
      } else {
        DateTime oldIso14001ValidDate = new DateTime(newQuality.getIso14001ValidDate());
        if (!updatedIso14001ValidDate.equals(oldIso14001ValidDate)) {
          changedInfo.put(
              ChangedInfoKeys.qualityISO14001ValidDate(),
              updatedIso14001ValidDate.toString(FORMATTER));
          updatedQuality.setIso14001ValidDate(null);
        }
      }
    }

    if (!Objects.equal(updatedQuality.getTs16949Id(), newQuality.getTs16949Id())) {
      changedInfo.put(ChangedInfoKeys.qualityTS16949Id(), updatedQuality.getTs16949Id());
      updatedQuality.setTs16949Id(null);
    }
    if (!Objects.equal(updatedQuality.getTs16949AttachUrl(), newQuality.getTs16949AttachUrl())) {
      changedInfo.put(
          ChangedInfoKeys.qualityTS16949AttachUrl(), updatedQuality.getTs16949AttachUrl());
      updatedQuality.setTs16949AttachUrl(null);
    }

    if (updatedQuality.getTs16949ValidDate() != null) {
      DateTime updatedTs16949ValidDate = new DateTime(updatedQuality.getTs16949ValidDate());
      if (newQuality.getTs16949ValidDate() == null) {
        changedInfo.put(
            ChangedInfoKeys.qualityTS16949ValidDate(), updatedTs16949ValidDate.toString(FORMATTER));
        updatedQuality.setTs16949ValidDate(null);
      } else {
        DateTime oldTs16949ValidDate = new DateTime(newQuality.getTs16949ValidDate());
        if (!updatedTs16949ValidDate.equals(oldTs16949ValidDate)) {
          changedInfo.put(
              ChangedInfoKeys.qualityTS16949ValidDate(),
              updatedTs16949ValidDate.toString(FORMATTER));
          updatedQuality.setTs16949ValidDate(null);
        }
      }
    }

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