@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<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; }