Browse Source

[fix]基础资料

修改汇率管理前端列表页面:实现开始时间和结束时间改为:汇率时间区间查找;
修改汇率管理后端修改接口:实现,只有修改时间的数据才会进行时间交叉和开始时间与结束时间的对比;并且修改的时候要排除此修改时间数据的id,防止修改不了数据的问题
新增 查询时间交叉,并且排除当前id后端接口
dev
liuxiaoxu 2 weeks ago
parent
commit
880ea25de0
  1. 12
      ruoyi-admin/src/main/java/com/ruoyi/system/mapper/BaseExchangeRateMapper.java
  2. 30
      ruoyi-admin/src/main/java/com/ruoyi/system/service/impl/BaseExchangeRateServiceImpl.java
  3. 6
      ruoyi-admin/src/main/resources/mapper/system/BaseExchangeRateMapper.xml
  4. 6
      ruoyi-admin/src/main/resources/templates/system/exchangeRate/exchangeRate.html

12
ruoyi-admin/src/main/java/com/ruoyi/system/mapper/BaseExchangeRateMapper.java

@ -43,6 +43,15 @@ public interface BaseExchangeRateMapper
*/
public List<BaseExchangeRate> selectExchangeRateByTimeRange(BaseExchangeRate baseExchangeRate);
/**
* 查询时间交叉,并且排除当前id
*
* @param baseExchangeRate 基础资料汇率管理
* @return 基础资料汇率管理集合
*/
List<BaseExchangeRate> selectExchangeRateByTimeRangeAndExcludeId(BaseExchangeRate baseExchangeRate);
/**
* 新增基础资料汇率管理
*
@ -90,4 +99,7 @@ public interface BaseExchangeRateMapper
* @return 结果
*/
public int restoreBaseExchangeRateById(Long exchangeRateId);
}

30
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());
Long exchangeRateId = baseExchangeRate.getExchangeRateId();
BaseExchangeRate oldExchangeRate = baseExchangeRateMapper.selectBaseExchangeRateById(exchangeRateId);
// 检查时间字段是否发生变化
boolean timeFieldsChanged = !baseExchangeRate.getStartTime().equals(oldExchangeRate.getStartTime()) ||
!baseExchangeRate.getEndTime().equals(oldExchangeRate.getEndTime());
if (timeFieldsChanged) {
Date startTime = baseExchangeRate.getStartTime();
Date endTime = baseExchangeRate.getEndTime();
if (startTime.after(endTime)){
throw new BusinessException("新增汇率失败!开始时间不能大于结束时间!");
if (startTime.after(endTime)) {
throw new BusinessException("修改汇率失败!开始时间不能大于结束时间!");
}
List<BaseExchangeRate> exchangeRates = baseExchangeRateMapper.selectExchangeRateByTimeRange(baseExchangeRate);
if (!CollectionUtils.isEmpty(exchangeRates)){
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("修改汇率数据修改记录失败");
}
}

6
ruoyi-admin/src/main/resources/mapper/system/BaseExchangeRateMapper.xml

@ -45,6 +45,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
WHERE start_time &lt;= #{endTime} AND end_time &gt;= #{startTime}
</select>
<select id="selectExchangeRateByTimeRangeAndExcludeId" parameterType="BaseExchangeRate" resultMap="BaseExchangeRateResult">
<include refid="selectBaseExchangeRateVo"/>
WHERE start_time &lt;= #{endTime} AND end_time &gt;= #{startTime}
AND exchange_rate_id != #{exchangeRateId}
</select>
<insert id="insertBaseExchangeRate" parameterType="BaseExchangeRate" useGeneratedKeys="true" keyProperty="exchangeRateId">
insert into base_exchange_rate
<trim prefix="(" suffix=")" suffixOverrides=",">

6
ruoyi-admin/src/main/resources/templates/system/exchangeRate/exchangeRate.html

@ -11,11 +11,13 @@
<div class="select-list">
<ul>
<li>
<label>开始时间:</label>
<label>汇率时间区间:</label>
<input type="text" class="time-input" placeholder="请选择开始时间" name="startTime"/>
</li>
<li>
<label>结束时间:</label>
<span>-</span>
</li>
<li>
<input type="text" class="time-input" placeholder="请选择结束时间" name="endTime"/>
</li>
<li>

Loading…
Cancel
Save