Browse Source

[feat]基础资料

汇率管理新增页面:添加汇率字段的时候,新增函数校验,汇率只能填写数字,添加其他字符会进行提示,不能正常提交
汇率管理修改页面:添加汇率字段的时候,新增函数校验,汇率只能填写数字,添加其他字符会进行提示,不能正常提交
汇率管理前端列表页面:
新增上次更新时间字段,新增双击上次更新时间打开修改记录数据页面的方法,上次更新时间字段加上颜色标注;新增开始时间和结束时间的查询方法
全局业务模块常量BusinessKeysConstants新增基础资料汇率管理SYS_EXCHANGE_RATE = "5"
汇率管理实体类:汇率、开始时间、结束时间新增@FieldCompare注解
修改汇率管理的新增后端接口:新增插入一条数据的同时在通用修改记录里面加上一条数据,并且加上事务处理
修改汇率管理的修改后端接口:新增修改汇率管理信息同时,引用FieldCompareUtil.compare方法进行前后数据对比,并且引用
diffLogService.updateSysDiffLogByBusiness通用方法处理修改后的数据,并且加上事务处理和异常处理;并且加上插入数据之前进行判断,1:开始时间不能大于结束时间!;2:不同数据之间的开始时间和结束时间不可以存在交叉数据,满足上面条件才可以添加
修改汇率管理的mapper.xml层的分页查询接口:使其满足可以通过开始时间和结束时间的区间进行分页查询
dev
liuxiaoxu 4 weeks ago
parent
commit
6a1230f6f2
  1. 4
      ruoyi-admin/src/main/java/com/ruoyi/system/domain/BaseExchangeRate.java
  2. 45
      ruoyi-admin/src/main/java/com/ruoyi/system/service/impl/BaseExchangeRateServiceImpl.java
  3. 7
      ruoyi-admin/src/main/resources/mapper/system/BaseExchangeRateMapper.xml
  4. 11
      ruoyi-admin/src/main/resources/templates/system/exchangeRate/add.html
  5. 5
      ruoyi-admin/src/main/resources/templates/system/exchangeRate/edit.html
  6. 16
      ruoyi-admin/src/main/resources/templates/system/exchangeRate/exchangeRate.html
  7. 3
      ruoyi-common/src/main/java/com/ruoyi/common/constant/BusinessKeysConstants.java

4
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;

45
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<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){
throw new BusinessException("修改汇率数据修改记录失败");
}
}
return baseExchangeRateMapper.updateBaseExchangeRate(baseExchangeRate);
}

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

@ -22,9 +22,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<select id="selectBaseExchangeRateList" parameterType="BaseExchangeRate" resultMap="BaseExchangeRateResult">
<include refid="selectBaseExchangeRateVo"/>
<where>
<if test="startTime != null "> and start_time = #{startTime}</if>
<if test="endTime != null "> and end_time = #{endTime}</if>
<where>
<if test="startTime != null and endTime != null">
start_time &lt;= #{endTime} AND end_time &gt;= #{startTime}
</if>
</where>
</select>

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

@ -28,7 +28,7 @@
<div class="form-group">
<label class="col-sm-3 control-label is-required">汇率:</label>
<div class="col-sm-8">
<input name="exchangeRate" class="form-control" type="text" required>
<input name="exchangeRate" class="form-control" type="text" required >
</div>
</div>
<!-- <div class="form-group"> -->
@ -43,7 +43,14 @@
<th:block th:include="include :: datetimepicker-js" />
<script th:inline="javascript">
var prefix = ctx + "system/exchangeRate"
$("#form-exchangeRate-add").validate({
$("#form-exchangeRate-add").validate(
{
rules: {
exchangeRate: {
number: true,
},
},
focusCleanup: true
});

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

@ -45,6 +45,11 @@
<script th:inline="javascript">
var prefix = ctx + "system/exchangeRate";
$("#form-exchangeRate-edit").validate({
rules: {
exchangeRate: {
number: true,
},
},
focusCleanup: true
});

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

@ -50,6 +50,15 @@
updateUrl: prefix + "/edit/{id}",
removeUrl: prefix + "/remove",
modalName: "汇率管理",
onDblClickCell: function(field, value, row, $element) {
var businessId = row.exchangeRateId;
var businessKey = "5";
if(field == 'updateTime'){
var url = ctx + "system/diffLog/getDiffDataList/" + businessId + "/" + businessKey;
$.modal.open("数据修改记录", url);
}
}, //双击单列字段触发事件
columns: [
{
title: '汇率ID',
@ -82,6 +91,13 @@
title: '上次更新时间',
field: 'updateTime',
align: 'center',
formatter: function(value, row, index) {
if (value) {
return '<span style="color:#337ab7; cursor: pointer;">' + value + '</span>';
} else {
return value;
}
}
},
{
title: '操作',

3
ruoyi-common/src/main/java/com/ruoyi/common/constant/BusinessKeysConstants.java

@ -23,4 +23,7 @@ public class BusinessKeysConstants {
/** 工程物料信息 */
public static final String ERP_MATERIAL = "4";
/** 基础资料汇率管理*/
public static final String SYS_EXCHANGE_RATE = "5";
}

Loading…
Cancel
Save