diff --git a/ruoyi-admin/src/main/java/com/ruoyi/system/mapper/BaseExchangeRateMapper.java b/ruoyi-admin/src/main/java/com/ruoyi/system/mapper/BaseExchangeRateMapper.java index e276830d..0ff81b8a 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/system/mapper/BaseExchangeRateMapper.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/system/mapper/BaseExchangeRateMapper.java @@ -43,6 +43,15 @@ public interface BaseExchangeRateMapper */ public List selectExchangeRateByTimeRange(BaseExchangeRate baseExchangeRate); + /** + * 查询时间交叉,并且排除当前id + * + * @param baseExchangeRate 基础资料汇率管理 + * @return 基础资料汇率管理集合 + */ + List selectExchangeRateByTimeRangeAndExcludeId(BaseExchangeRate baseExchangeRate); + + /** * 新增基础资料汇率管理 * @@ -90,4 +99,7 @@ public interface BaseExchangeRateMapper * @return 结果 */ public int restoreBaseExchangeRateById(Long exchangeRateId); + + + } diff --git a/ruoyi-admin/src/main/java/com/ruoyi/system/service/impl/BaseExchangeRateServiceImpl.java b/ruoyi-admin/src/main/java/com/ruoyi/system/service/impl/BaseExchangeRateServiceImpl.java index 329114f2..247431ec 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/system/service/impl/BaseExchangeRateServiceImpl.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/system/service/impl/BaseExchangeRateServiceImpl.java @@ -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 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 exchangeRates = baseExchangeRateMapper.selectExchangeRateByTimeRangeAndExcludeId(baseExchangeRate); + + // List exchangeRates = baseExchangeRateMapper.selectExchangeRateByTimeRange(baseExchangeRate); + if (!CollectionUtils.isEmpty(exchangeRates)) { + throw new BusinessException("修改汇率失败!该时间段内已存在汇率数据!"); + } } - Long exchangeRateId = baseExchangeRate.getExchangeRateId(); - BaseExchangeRate oldExchangeRate = baseExchangeRateMapper.selectBaseExchangeRateById(exchangeRateId); + List 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("修改汇率数据修改记录失败"); } } diff --git a/ruoyi-admin/src/main/resources/mapper/sales/SalesShippingInformationMapper.xml b/ruoyi-admin/src/main/resources/mapper/sales/SalesShippingInformationMapper.xml index ab7bb871..67b14455 100644 --- a/ruoyi-admin/src/main/resources/mapper/sales/SalesShippingInformationMapper.xml +++ b/ruoyi-admin/src/main/resources/mapper/sales/SalesShippingInformationMapper.xml @@ -47,13 +47,13 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" diff --git a/ruoyi-admin/src/main/resources/mapper/system/BaseExchangeRateMapper.xml b/ruoyi-admin/src/main/resources/mapper/system/BaseExchangeRateMapper.xml index fc2c8fed..4f0c19d7 100644 --- a/ruoyi-admin/src/main/resources/mapper/system/BaseExchangeRateMapper.xml +++ b/ruoyi-admin/src/main/resources/mapper/system/BaseExchangeRateMapper.xml @@ -45,6 +45,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" WHERE start_time <= #{endTime} AND end_time >= #{startTime} + + insert into base_exchange_rate diff --git a/ruoyi-admin/src/main/resources/mapper/system/SysSalesShippingInformMapper.xml b/ruoyi-admin/src/main/resources/mapper/system/SysSalesShippingInformMapper.xml index ad3fd959..a5a150db 100644 --- a/ruoyi-admin/src/main/resources/mapper/system/SysSalesShippingInformMapper.xml +++ b/ruoyi-admin/src/main/resources/mapper/system/SysSalesShippingInformMapper.xml @@ -45,9 +45,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
  • - + - +
  • +