From 880ea25de076baaefaf4babf0c8c571d8105332b Mon Sep 17 00:00:00 2001 From: liuxiaoxu <1793812695@qq.com> Date: Fri, 8 Nov 2024 16:02:42 +0800 Subject: [PATCH] =?UTF-8?q?[fix]=E5=9F=BA=E7=A1=80=E8=B5=84=E6=96=99=20?= =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=B1=87=E7=8E=87=E7=AE=A1=E7=90=86=E5=89=8D?= =?UTF-8?q?=E7=AB=AF=E5=88=97=E8=A1=A8=E9=A1=B5=E9=9D=A2=EF=BC=9A=E5=AE=9E?= =?UTF-8?q?=E7=8E=B0=E5=BC=80=E5=A7=8B=E6=97=B6=E9=97=B4=E5=92=8C=E7=BB=93?= =?UTF-8?q?=E6=9D=9F=E6=97=B6=E9=97=B4=E6=94=B9=E4=B8=BA=EF=BC=9A=E6=B1=87?= =?UTF-8?q?=E7=8E=87=E6=97=B6=E9=97=B4=E5=8C=BA=E9=97=B4=E6=9F=A5=E6=89=BE?= =?UTF-8?q?=EF=BC=9B=20=E4=BF=AE=E6=94=B9=E6=B1=87=E7=8E=87=E7=AE=A1?= =?UTF-8?q?=E7=90=86=E5=90=8E=E7=AB=AF=E4=BF=AE=E6=94=B9=E6=8E=A5=E5=8F=A3?= =?UTF-8?q?=EF=BC=9A=E5=AE=9E=E7=8E=B0=EF=BC=8C=E5=8F=AA=E6=9C=89=E4=BF=AE?= =?UTF-8?q?=E6=94=B9=E6=97=B6=E9=97=B4=E7=9A=84=E6=95=B0=E6=8D=AE=E6=89=8D?= =?UTF-8?q?=E4=BC=9A=E8=BF=9B=E8=A1=8C=E6=97=B6=E9=97=B4=E4=BA=A4=E5=8F=89?= =?UTF-8?q?=E5=92=8C=E5=BC=80=E5=A7=8B=E6=97=B6=E9=97=B4=E4=B8=8E=E7=BB=93?= =?UTF-8?q?=E6=9D=9F=E6=97=B6=E9=97=B4=E7=9A=84=E5=AF=B9=E6=AF=94=EF=BC=9B?= =?UTF-8?q?=E5=B9=B6=E4=B8=94=E4=BF=AE=E6=94=B9=E7=9A=84=E6=97=B6=E5=80=99?= =?UTF-8?q?=E8=A6=81=E6=8E=92=E9=99=A4=E6=AD=A4=E4=BF=AE=E6=94=B9=E6=97=B6?= =?UTF-8?q?=E9=97=B4=E6=95=B0=E6=8D=AE=E7=9A=84id=EF=BC=8C=E9=98=B2?= =?UTF-8?q?=E6=AD=A2=E4=BF=AE=E6=94=B9=E4=B8=8D=E4=BA=86=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=E7=9A=84=E9=97=AE=E9=A2=98=20=E6=96=B0=E5=A2=9E=20=E6=9F=A5?= =?UTF-8?q?=E8=AF=A2=E6=97=B6=E9=97=B4=E4=BA=A4=E5=8F=89,=E5=B9=B6?= =?UTF-8?q?=E4=B8=94=E6=8E=92=E9=99=A4=E5=BD=93=E5=89=8Did=E5=90=8E?= =?UTF-8?q?=E7=AB=AF=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../system/mapper/BaseExchangeRateMapper.java | 12 +++++++ .../impl/BaseExchangeRateServiceImpl.java | 36 ++++++++++++------- .../mapper/system/BaseExchangeRateMapper.xml | 6 ++++ .../system/exchangeRate/exchangeRate.html | 6 ++-- 4 files changed, 45 insertions(+), 15 deletions(-) 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/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/templates/system/exchangeRate/exchangeRate.html b/ruoyi-admin/src/main/resources/templates/system/exchangeRate/exchangeRate.html index b0ae01c8..4bfb13fa 100644 --- a/ruoyi-admin/src/main/resources/templates/system/exchangeRate/exchangeRate.html +++ b/ruoyi-admin/src/main/resources/templates/system/exchangeRate/exchangeRate.html @@ -11,11 +11,13 @@
  • - +
  • - + - +
  • +