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