From 6a1230f6f28631e6d2dc2894877e251049ae4b1e Mon Sep 17 00:00:00 2001 From: liuxiaoxu <1793812695@qq.com> Date: Tue, 29 Oct 2024 13:34:34 +0800 Subject: [PATCH] =?UTF-8?q?[feat]=E5=9F=BA=E7=A1=80=E8=B5=84=E6=96=99=20?= =?UTF-8?q?=E6=B1=87=E7=8E=87=E7=AE=A1=E7=90=86=E6=96=B0=E5=A2=9E=E9=A1=B5?= =?UTF-8?q?=E9=9D=A2=EF=BC=9A=E6=B7=BB=E5=8A=A0=E6=B1=87=E7=8E=87=E5=AD=97?= =?UTF-8?q?=E6=AE=B5=E7=9A=84=E6=97=B6=E5=80=99=EF=BC=8C=E6=96=B0=E5=A2=9E?= =?UTF-8?q?=E5=87=BD=E6=95=B0=E6=A0=A1=E9=AA=8C=EF=BC=8C=E6=B1=87=E7=8E=87?= =?UTF-8?q?=E5=8F=AA=E8=83=BD=E5=A1=AB=E5=86=99=E6=95=B0=E5=AD=97=EF=BC=8C?= =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=85=B6=E4=BB=96=E5=AD=97=E7=AC=A6=E4=BC=9A?= =?UTF-8?q?=E8=BF=9B=E8=A1=8C=E6=8F=90=E7=A4=BA=EF=BC=8C=E4=B8=8D=E8=83=BD?= =?UTF-8?q?=E6=AD=A3=E5=B8=B8=E6=8F=90=E4=BA=A4=20=E6=B1=87=E7=8E=87?= =?UTF-8?q?=E7=AE=A1=E7=90=86=E4=BF=AE=E6=94=B9=E9=A1=B5=E9=9D=A2=EF=BC=9A?= =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E6=B1=87=E7=8E=87=E5=AD=97=E6=AE=B5=E7=9A=84?= =?UTF-8?q?=E6=97=B6=E5=80=99=EF=BC=8C=E6=96=B0=E5=A2=9E=E5=87=BD=E6=95=B0?= =?UTF-8?q?=E6=A0=A1=E9=AA=8C=EF=BC=8C=E6=B1=87=E7=8E=87=E5=8F=AA=E8=83=BD?= =?UTF-8?q?=E5=A1=AB=E5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=90=86?= =?UTF-8?q?=E7=9A=84=E4=BF=AE=E6=94=B9=E5=90=8E=E7=AB=AF=E6=8E=A5=E5=8F=A3?= =?UTF-8?q?=EF=BC=9A=E6=96=B0=E5=A2=9E=E4=BF=AE=E6=94=B9=E6=B1=87=E7=8E=87?= =?UTF-8?q?=E7=AE=A1=E7=90=86=E4=BF=A1=E6=81=AF=E5=90=8C=E6=97=B6=EF=BC=8C?= =?UTF-8?q?=E5=BC=95=E7=94=A8FieldCompareUtil.compare=E6=96=B9=E6=B3=95?= =?UTF-8?q?=E8=BF=9B=E8=A1=8C=E5=89=8D=E5=90=8E=E6=95=B0=E6=8D=AE=E5=AF=B9?= =?UTF-8?q?=E6=AF=94=EF=BC=8C=E5=B9=B6=E4=B8=94=E5=BC=95=E7=94=A8=20diffLo?= =?UTF-8?q?gService.updateSysDiffLogByBusiness=E9=80=9A=E7=94=A8=E6=96=B9?= =?UTF-8?q?=E6=B3=95=E5=A4=84=E7=90=86=E4=BF=AE=E6=94=B9=E5=90=8E=E7=9A=84?= =?UTF-8?q?=E6=95=B0=E6=8D=AE=EF=BC=8C=E5=B9=B6=E4=B8=94=E5=8A=A0=E4=B8=8A?= =?UTF-8?q?=E4=BA=8B=E5=8A=A1=E5=A4=84=E7=90=86=E5=92=8C=E5=BC=82=E5=B8=B8?= =?UTF-8?q?=E5=A4=84=E7=90=86=EF=BC=9B=E5=B9=B6=E4=B8=94=E5=8A=A0=E4=B8=8A?= =?UTF-8?q?=E6=8F=92=E5=85=A5=E6=95=B0=E6=8D=AE=E4=B9=8B=E5=89=8D=E8=BF=9B?= =?UTF-8?q?=E8=A1=8C=E5=88=A4=E6=96=AD=EF=BC=8C1=EF=BC=9A=E5=BC=80?= =?UTF-8?q?=E5=A7=8B=E6=97=B6=E9=97=B4=E4=B8=8D=E8=83=BD=E5=A4=A7=E4=BA=8E?= =?UTF-8?q?=E7=BB=93=E6=9D=9F=E6=97=B6=E9=97=B4=EF=BC=81=EF=BC=9B2?= =?UTF-8?q?=EF=BC=9A=E4=B8=8D=E5=90=8C=E6=95=B0=E6=8D=AE=E4=B9=8B=E9=97=B4?= =?UTF-8?q?=E7=9A=84=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=E4=B8=8D=E5=8F=AF=E4=BB=A5=E5=AD=98?= =?UTF-8?q?=E5=9C=A8=E4=BA=A4=E5=8F=89=E6=95=B0=E6=8D=AE=EF=BC=8C=E6=BB=A1?= =?UTF-8?q?=E8=B6=B3=E4=B8=8A=E9=9D=A2=E6=9D=A1=E4=BB=B6=E6=89=8D=E5=8F=AF?= =?UTF-8?q?=E4=BB=A5=E6=B7=BB=E5=8A=A0=20=E4=BF=AE=E6=94=B9=E6=B1=87?= =?UTF-8?q?=E7=8E=87=E7=AE=A1=E7=90=86=E7=9A=84mapper.xml=E5=B1=82?= =?UTF-8?q?=E7=9A=84=E5=88=86=E9=A1=B5=E6=9F=A5=E8=AF=A2=E6=8E=A5=E5=8F=A3?= =?UTF-8?q?=EF=BC=9A=E4=BD=BF=E5=85=B6=E6=BB=A1=E8=B6=B3=E5=8F=AF=E4=BB=A5?= =?UTF-8?q?=E9=80=9A=E8=BF=87=E5=BC=80=E5=A7=8B=E6=97=B6=E9=97=B4=E5=92=8C?= =?UTF-8?q?=E7=BB=93=E6=9D=9F=E6=97=B6=E9=97=B4=E7=9A=84=E5=8C=BA=E9=97=B4?= =?UTF-8?q?=E8=BF=9B=E8=A1=8C=E5=88=86=E9=A1=B5=E6=9F=A5=E8=AF=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ruoyi/system/domain/BaseExchangeRate.java | 4 ++ .../impl/BaseExchangeRateServiceImpl.java | 45 ++++++++++++++++++- .../mapper/system/BaseExchangeRateMapper.xml | 7 +-- .../templates/system/exchangeRate/add.html | 11 ++++- .../templates/system/exchangeRate/edit.html | 5 +++ .../system/exchangeRate/exchangeRate.html | 16 +++++++ .../constant/BusinessKeysConstants.java | 3 ++ 7 files changed, 85 insertions(+), 6 deletions(-) diff --git a/ruoyi-admin/src/main/java/com/ruoyi/system/domain/BaseExchangeRate.java b/ruoyi-admin/src/main/java/com/ruoyi/system/domain/BaseExchangeRate.java index adbaff08..b1005151 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/system/domain/BaseExchangeRate.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/system/domain/BaseExchangeRate.java @@ -3,6 +3,7 @@ package com.ruoyi.system.domain; import java.math.BigDecimal; import java.util.Date; import com.fasterxml.jackson.annotation.JsonFormat; +import com.ruoyi.common.annotation.FieldCompare; import org.apache.commons.lang3.builder.ToStringBuilder; import org.apache.commons.lang3.builder.ToStringStyle; import com.ruoyi.common.annotation.Excel; @@ -22,15 +23,18 @@ public class BaseExchangeRate extends BaseEntity private Long exchangeRateId; /** 汇率 */ + @FieldCompare(chineseName = "汇率") @Excel(name = "汇率") private BigDecimal exchangeRate; /** 开始时间 */ + @FieldCompare(chineseName = "开始时间") @JsonFormat(pattern = "yyyy-MM-dd") @Excel(name = "开始时间", width = 30, dateFormat = "yyyy-MM-dd") private Date startTime; /** 结束时间 */ + @FieldCompare(chineseName = "结束时间") @JsonFormat(pattern = "yyyy-MM-dd") @Excel(name = "结束时间", width = 30, dateFormat = "yyyy-MM-dd") private Date endTime; 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 7dd0dacd..9a5561f6 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 @@ -3,16 +3,22 @@ package com.ruoyi.system.service.impl; import java.util.Date; import java.util.List; +import com.ruoyi.common.constant.BusinessKeysConstants; +import com.ruoyi.common.core.domain.entity.SysFieldDifferent; import com.ruoyi.common.exception.BusinessException; import com.ruoyi.common.utils.DateUtils; +import com.ruoyi.common.utils.FieldCompareUtil; import com.ruoyi.common.utils.ShiroUtils; +import com.ruoyi.system.domain.SysDiffLog; import com.ruoyi.system.service.ISysDiffLogService; +import lombok.SneakyThrows; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import com.ruoyi.system.mapper.BaseExchangeRateMapper; import com.ruoyi.system.domain.BaseExchangeRate; import com.ruoyi.system.service.IBaseExchangeRateService; import com.ruoyi.common.core.text.Convert; +import org.springframework.transaction.annotation.Transactional; import org.springframework.util.CollectionUtils; /** @@ -27,6 +33,8 @@ public class BaseExchangeRateServiceImpl implements IBaseExchangeRateService @Autowired private BaseExchangeRateMapper baseExchangeRateMapper; + @Autowired + private ISysDiffLogService diffLogService; /** * 查询基础资料汇率管理 @@ -58,6 +66,7 @@ public class BaseExchangeRateServiceImpl implements IBaseExchangeRateService * @param baseExchangeRate 基础资料汇率管理 * @return 结果 */ + @Transactional(rollbackFor = Exception.class) @Override public int insertBaseExchangeRate(BaseExchangeRate baseExchangeRate) { @@ -75,7 +84,18 @@ public class BaseExchangeRateServiceImpl implements IBaseExchangeRateService if (!CollectionUtils.isEmpty(exchangeRates)){ throw new BusinessException("新增汇率失败!该时间段内已存在汇率数据!"); } - return baseExchangeRateMapper.insertBaseExchangeRate(baseExchangeRate); + + int result = baseExchangeRateMapper.insertBaseExchangeRate(baseExchangeRate); + + Long exchangeRateId = baseExchangeRate.getExchangeRateId(); + SysDiffLog sysDiffLog = new SysDiffLog(); + sysDiffLog.setBusinessId(exchangeRateId); + sysDiffLog.setBusinessKey(BusinessKeysConstants.SYS_EXCHANGE_RATE); + int insertSysDiffLog = diffLogService.insertSysDiffLog(sysDiffLog); + if (insertSysDiffLog <= 0){ + throw new BusinessException("新增汇率数据修改记录失败"); + } + return result; } /** @@ -84,12 +104,35 @@ public class BaseExchangeRateServiceImpl implements IBaseExchangeRateService * @param baseExchangeRate 基础资料汇率管理 * @return 结果 */ + @SneakyThrows + @Transactional(rollbackFor = Exception.class) @Override public int updateBaseExchangeRate(BaseExchangeRate baseExchangeRate) { String loginName = ShiroUtils.getLoginName(); baseExchangeRate.setUpdateBy(loginName); baseExchangeRate.setUpdateTime(DateUtils.getNowDate()); + Date startTime = baseExchangeRate.getStartTime(); + Date endTime = baseExchangeRate.getEndTime(); + + if (startTime.after(endTime)){ + throw new BusinessException("新增汇率失败!开始时间不能大于结束时间!"); + } + + 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){ + throw new BusinessException("修改汇率数据修改记录失败"); + } + } + return baseExchangeRateMapper.updateBaseExchangeRate(baseExchangeRate); } diff --git a/ruoyi-admin/src/main/resources/mapper/system/BaseExchangeRateMapper.xml b/ruoyi-admin/src/main/resources/mapper/system/BaseExchangeRateMapper.xml index 2147e1cf..54234d0a 100644 --- a/ruoyi-admin/src/main/resources/mapper/system/BaseExchangeRateMapper.xml +++ b/ruoyi-admin/src/main/resources/mapper/system/BaseExchangeRateMapper.xml @@ -22,9 +22,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" diff --git a/ruoyi-admin/src/main/resources/templates/system/exchangeRate/add.html b/ruoyi-admin/src/main/resources/templates/system/exchangeRate/add.html index 7aae6e7f..06c7d6b6 100644 --- a/ruoyi-admin/src/main/resources/templates/system/exchangeRate/add.html +++ b/ruoyi-admin/src/main/resources/templates/system/exchangeRate/add.html @@ -28,7 +28,7 @@
- +
@@ -43,7 +43,14 @@