public List<QutationModifyRecord> findQuotationModifyRecord( Long quotationMainId, LocaleConstants locale) { QuotationMain main = quotationMainService.findById(quotationMainId); List<ModifyRecord> list = modifyRecordRepository.findByTableNameAndModifiedDataIdOrderByCreateTimeDesc( MODIFY_RECORD_TABLE_NAME, quotationMainId); List<QutationModifyRecord> result = new ArrayList<QutationModifyRecord>(); for (ModifyRecord record : list) { QutationModifyRecord res = convertQuotationRecord(record, locale, main.getBusinessType()); result.add(res); } return result; }
/** * 功能描述: 保存Main的修改记录 创建人:yudajun 创建时间:2014-4-22 下午5:36:00 修改人:yudajun 修改时间:2014-4-22 下午5:36:00 * 修改备注: 参数: * * @version */ public boolean saveQuotationMainModifyRecord(QuotationMain oldObject, QuotationMain newObject) { boolean result = false; List<ModifyRecord> recordList = new ArrayList<ModifyRecord>(); if (oldObject != null && newObject != null && newObject.getId() != null && newObject.getId().equals(oldObject.getId())) { if (!newObject.getBusinessType().equals(oldObject.getBusinessType())) { ModifyRecord record = getNewModifyRecord(newObject.getId()); record.setOperateType(OperateType.modify); record.setModifyField(MODIFY_RECORD_FIELD_BUSSINESSTYPE); record.setOldValue(String.valueOf(oldObject.getBusinessType().ordinal())); record.setNewValue(String.valueOf(newObject.getBusinessType().ordinal())); recordList.add(record); } else { if (!newObject.getAdvertisingPlatformId().equals(oldObject.getAdvertisingPlatformId())) { ModifyRecord record = getNewModifyRecord(newObject.getId()); record.setOperateType(OperateType.modify); record.setModifyField(MODIFY_RECORD_FIELD_PLATFORM); record.setOldValue(String.valueOf(oldObject.getAdvertisingPlatformId())); record.setNewValue(String.valueOf(newObject.getAdvertisingPlatformId())); recordList.add(record); } else { if (!newObject.getPriceType().equals(oldObject.getPriceType())) { ModifyRecord record = getNewModifyRecord(newObject.getId()); record.setOperateType(OperateType.modify); record.setModifyField(MODIFY_RECORD_FIELD_PRICETYPE); record.setOldValue(String.valueOf(oldObject.getPriceType().ordinal())); record.setNewValue(String.valueOf(newObject.getPriceType().ordinal())); recordList.add(record); } else { if (!oldObject.getSiteId().equals(newObject.getSiteId())) { ModifyRecord record = getNewModifyRecord(newObject.getId()); record.setOperateType(OperateType.modify); record.setModifyField(MODIFY_RECORD_FIELD_SITE); record.setOldValue(oldObject.getSiteId().toString()); record.setNewValue(newObject.getSiteId().toString()); recordList.add(record); } else { if (DateUtils.compareDate( newObject.getStartTime(), oldObject.getStartTime(), DateUtils.YYYY_MM_DD) != 0 || DateUtils.compareDate( newObject.getEndTime(), oldObject.getEndTime(), DateUtils.YYYY_MM_DD) != 0) { ModifyRecord record = getNewModifyRecord(newObject.getId()); record.setOperateType(OperateType.modify); record.setModifyField(MODIFY_RECORD_FIELD_VALIDDATE); record.setOldValue( DateUtils.getDate2String(DateUtils.YYYY_MM_DD, oldObject.getStartTime()) + "~" + DateUtils.getDate2String(DateUtils.YYYY_MM_DD, oldObject.getEndTime())); record.setNewValue( DateUtils.getDate2String(DateUtils.YYYY_MM_DD, newObject.getStartTime()) + "~" + DateUtils.getDate2String(DateUtils.YYYY_MM_DD, newObject.getEndTime())); recordList.add(record); } result = true; // 如果仅修改时间 } } } } } if (CollectionUtils.isNotEmpty(recordList)) { modifyRecordRepository.save(recordList); } return result; }