|
|
@ -113,23 +113,33 @@ public class BaseExchangeRateServiceImpl implements IBaseExchangeRateService |
|
|
|
String loginName = ShiroUtils.getLoginName(); |
|
|
|
baseExchangeRate.setUpdateBy(loginName); |
|
|
|
baseExchangeRate.setUpdateTime(DateUtils.getNowDate()); |
|
|
|
Date startTime = baseExchangeRate.getStartTime(); |
|
|
|
Date endTime = baseExchangeRate.getEndTime(); |
|
|
|
Long exchangeRateId = baseExchangeRate.getExchangeRateId(); |
|
|
|
|
|
|
|
if (startTime.after(endTime)){ |
|
|
|
throw new BusinessException("新增汇率失败!开始时间不能大于结束时间!"); |
|
|
|
} |
|
|
|
BaseExchangeRate oldExchangeRate = baseExchangeRateMapper.selectBaseExchangeRateById(exchangeRateId); |
|
|
|
// 检查时间字段是否发生变化
|
|
|
|
boolean timeFieldsChanged = !baseExchangeRate.getStartTime().equals(oldExchangeRate.getStartTime()) || |
|
|
|
!baseExchangeRate.getEndTime().equals(oldExchangeRate.getEndTime()); |
|
|
|
|
|
|
|
List<BaseExchangeRate> exchangeRates = baseExchangeRateMapper.selectExchangeRateByTimeRange(baseExchangeRate); |
|
|
|
if (!CollectionUtils.isEmpty(exchangeRates)){ |
|
|
|
throw new BusinessException("新增汇率失败!该时间段内已存在汇率数据!"); |
|
|
|
if (timeFieldsChanged) { |
|
|
|
Date startTime = baseExchangeRate.getStartTime(); |
|
|
|
Date endTime = baseExchangeRate.getEndTime(); |
|
|
|
|
|
|
|
if (startTime.after(endTime)) { |
|
|
|
throw new BusinessException("修改汇率失败!开始时间不能大于结束时间!"); |
|
|
|
} |
|
|
|
|
|
|
|
List<BaseExchangeRate> exchangeRates = baseExchangeRateMapper.selectExchangeRateByTimeRangeAndExcludeId(baseExchangeRate); |
|
|
|
|
|
|
|
// List<BaseExchangeRate> exchangeRates = baseExchangeRateMapper.selectExchangeRateByTimeRange(baseExchangeRate);
|
|
|
|
if (!CollectionUtils.isEmpty(exchangeRates)) { |
|
|
|
throw new BusinessException("修改汇率失败!该时间段内已存在汇率数据!"); |
|
|
|
} |
|
|
|
} |
|
|
|
Long exchangeRateId = baseExchangeRate.getExchangeRateId(); |
|
|
|
BaseExchangeRate oldExchangeRate = baseExchangeRateMapper.selectBaseExchangeRateById(exchangeRateId); |
|
|
|
|
|
|
|
List<SysFieldDifferent> compare = FieldCompareUtil.compare(BaseExchangeRate.class, baseExchangeRate, oldExchangeRate); |
|
|
|
if (!CollectionUtils.isEmpty(compare)){ |
|
|
|
int updateSysDiffLog = diffLogService.updateSysDiffLogByBusiness(exchangeRateId,BusinessKeysConstants.SYS_EXCHANGE_RATE,compare); |
|
|
|
if (updateSysDiffLog <= 0){ |
|
|
|
if (!CollectionUtils.isEmpty(compare)) { |
|
|
|
int updateSysDiffLog = diffLogService.updateSysDiffLogByBusiness(exchangeRateId, BusinessKeysConstants.SYS_EXCHANGE_RATE, compare); |
|
|
|
if (updateSysDiffLog <= 0) { |
|
|
|
throw new BusinessException("修改汇率数据修改记录失败"); |
|
|
|
} |
|
|
|
} |
|
|
|