Browse Source

[feat]系统管理

根据单据创建时间查询当前区间内的美元汇率后端接口(所有模块通用):对比当前订单创建时间,在美元汇率管理的开始时间之后,在结束时间之前,并且包括临界值
新增 因为时间都没有包含时分秒,所以对比的时候设置时分秒为 00:00:00后端方法
新增 查询所有基础资料汇率管理列表后端方法
修改客户报价前端新增页面:实现
1、美元汇率,业务自己不可手动维护,根据报价单的当前时间,美元汇率从【基础资料-汇率管理】中获取当前时间的美元忽略
1.1、获取到美元汇率,则显示美元汇率
1.2、未获取到美元汇率,则显示“当前未配置美元汇率,请联系总经理”
三、确定
1、点击【新增物料】时,若当前时间未获取到当前的【美元汇率】,弹窗提示“当前未配置美元汇率,请联系总经理”
dev
liuxiaoxu 4 weeks ago
parent
commit
80ff2b649d
  1. 26
      ruoyi-admin/src/main/java/com/ruoyi/system/controller/BaseExchangeRateController.java
  2. 7
      ruoyi-admin/src/main/java/com/ruoyi/system/mapper/BaseExchangeRateMapper.java
  3. 5
      ruoyi-admin/src/main/java/com/ruoyi/system/service/IBaseExchangeRateService.java
  4. 40
      ruoyi-admin/src/main/java/com/ruoyi/system/service/impl/BaseExchangeRateServiceImpl.java
  5. 5
      ruoyi-admin/src/main/resources/mapper/system/BaseExchangeRateMapper.xml
  6. 53
      ruoyi-admin/src/main/resources/templates/system/customerQuote/add.html

26
ruoyi-admin/src/main/java/com/ruoyi/system/controller/BaseExchangeRateController.java

@ -1,15 +1,13 @@
package com.ruoyi.system.controller; package com.ruoyi.system.controller;
import java.math.BigDecimal;
import java.util.Date;
import java.util.List; import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions; import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller; import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap; import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log; import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType; import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.BaseExchangeRate; import com.ruoyi.system.domain.BaseExchangeRate;
@ -148,4 +146,22 @@ public class BaseExchangeRateController extends BaseController
} }
/**
*
* 根据单据创建时间查询当前区间内的美元汇率
* */
@GetMapping("/getLatestUsdTax")
@ResponseBody
public AjaxResult getExchangeRateByDate(){
Date curDate = new Date();
BaseExchangeRate baseExchangeRate = new BaseExchangeRate();
baseExchangeRate.setCreateTime(curDate);
//查询当前时间属于哪个区间,开始时间和结束时间之间。已经设置区间不能交叉
BaseExchangeRate tempBaseExchangeRate = baseExchangeRateService.selectExchangeRateByTimeRange(baseExchangeRate);
BigDecimal exchangeRate = tempBaseExchangeRate.getExchangeRate();
return AjaxResult.success(exchangeRate);
}
} }

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

@ -27,6 +27,13 @@ public interface BaseExchangeRateMapper
*/ */
public List<BaseExchangeRate> selectBaseExchangeRateList(BaseExchangeRate baseExchangeRate); public List<BaseExchangeRate> selectBaseExchangeRateList(BaseExchangeRate baseExchangeRate);
/**
* 查询所有基础资料汇率管理列表
*
* @return 基础资料汇率管理集合
*/
public List<BaseExchangeRate> selectAllBaseExchangeRate();
/** /**
* 查询时间交叉 * 查询时间交叉

5
ruoyi-admin/src/main/java/com/ruoyi/system/service/IBaseExchangeRateService.java

@ -72,4 +72,9 @@ public interface IBaseExchangeRateService
* @return * @return
*/ */
int restoreBaseExchangeRateById(Long exchangeRateId); int restoreBaseExchangeRateById(Long exchangeRateId);
/**
* 查找当前时间的汇率
* */
BaseExchangeRate selectExchangeRateByTimeRange(BaseExchangeRate baseExchangeRate);
} }

40
ruoyi-admin/src/main/java/com/ruoyi/system/service/impl/BaseExchangeRateServiceImpl.java

@ -1,5 +1,6 @@
package com.ruoyi.system.service.impl; package com.ruoyi.system.service.impl;
import java.util.Calendar;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
@ -183,4 +184,43 @@ public class BaseExchangeRateServiceImpl implements IBaseExchangeRateService
{ {
return baseExchangeRateMapper.restoreBaseExchangeRateById(exchangeRateId); return baseExchangeRateMapper.restoreBaseExchangeRateById(exchangeRateId);
} }
/**
* 查找当前时间的汇率
* */
@Override
public BaseExchangeRate selectExchangeRateByTimeRange(BaseExchangeRate baseExchangeRate) {
// 当前时间
Date curDate = baseExchangeRate.getCreateTime();
curDate = setToMidnight(curDate);
// 查找所有数据
List<BaseExchangeRate> baseExchangeRates = baseExchangeRateMapper.selectAllBaseExchangeRate();
// 比对当前时间,属于所有数据中的哪一个区间,包含临界值,返回该条数据的汇率
for (BaseExchangeRate tempBaseExchangeRate : baseExchangeRates) {
Date startTime = tempBaseExchangeRate.getStartTime();
startTime = setToMidnight(startTime);
Date endTime = tempBaseExchangeRate.getEndTime();
endTime = setToMidnight(endTime);
if (curDate.equals(startTime) || curDate.equals(endTime) ||
(curDate.after(startTime) && curDate.before(endTime))) {
return tempBaseExchangeRate;
}
}
return null;
}
//因为时间都没有包含时分秒,所以对比的时候设置时分秒为 00:00:00
private Date setToMidnight(Date date) {
Calendar calendar = Calendar.getInstance();
calendar.setTime(date);
calendar.set(Calendar.HOUR_OF_DAY, 0);
calendar.set(Calendar.MINUTE, 0);
calendar.set(Calendar.SECOND, 0);
calendar.set(Calendar.MILLISECOND, 0);
return calendar.getTime();
}
} }

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

@ -35,6 +35,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</select> </select>
<select id="selectAllBaseExchangeRate" resultMap="BaseExchangeRateResult">
<include refid="selectBaseExchangeRateVo"/>
</select>
<select id="selectExchangeRateByTimeRange" parameterType="BaseExchangeRate" resultMap="BaseExchangeRateResult"> <select id="selectExchangeRateByTimeRange" parameterType="BaseExchangeRate" resultMap="BaseExchangeRateResult">
<include refid="selectBaseExchangeRateVo"/> <include refid="selectBaseExchangeRateVo"/>
WHERE start_time &lt;= #{endTime} AND end_time &gt;= #{startTime} WHERE start_time &lt;= #{endTime} AND end_time &gt;= #{startTime}

53
ruoyi-admin/src/main/resources/templates/system/customerQuote/add.html

@ -53,18 +53,9 @@
<div class="form-group"> <div class="form-group">
<label class="col-sm-4 control-label is-required">美元汇率:</label> <label class="col-sm-4 control-label is-required">美元汇率:</label>
<div class="col-sm-8"> <div class="col-sm-8">
<input name="usdTax" id="usdTax_add" class="form-control" type="number" placeholder="美元对人民币汇率" required> <input name="usdTax" id="usdTax_add" class="form-control" type="number" placeholder="当前未配置美元汇率,请联系总经理" required readonly>
</div> </div>
</div> </div>
<!-- <div class="form-group">-->
<!-- <label class="col-sm-4 control-label is-required">是否含税:</label>-->
<!-- <div class="radio-box" th:each="dict : ${@dict.getType('sys_confirm_tax')}">-->
<!-- <input required type="radio" th:id="${'confirmFax_' + dict.dictCode}"-->
<!-- name="confirmFax" th:value="${dict.dictValue}" >-->
<!-- <label th:for="${'confirmFax_' + dict.dictCode}" th:text="${dict.dictLabel}"></label>-->
<!-- </div>-->
<!-- </div>-->
<div class="form-group"> <div class="form-group">
<label class="col-sm-4 control-label is-required">是否含税:</label> <label class="col-sm-4 control-label is-required">是否含税:</label>
@ -79,18 +70,6 @@
</div> </div>
</div> </div>
<!-- <div class="form-group">-->
<!-- <label class="col-sm-4 control-label is-required">是否含税:</label>-->
<!-- <div class="radio-box">-->
<!-- <input required type="radio" id="confirmTax_yes" name="confirmTax" value="0">-->
<!-- <label for="confirmTax_yes">含税</label>-->
<!-- </div>-->
<!-- <div class="radio-box">-->
<!-- <input required type="radio" id="confirmTax_no" name="confirmTax" value="1">-->
<!-- <label for="confirmTax_no">不含税</label>-->
<!-- </div>-->
<!-- </div>-->
<div class="form-group"> <div class="form-group">
<label class="col-sm-4 control-label">国内税率:</label> <label class="col-sm-4 control-label">国内税率:</label>
<div class="col-sm-8"> <div class="col-sm-8">
@ -176,7 +155,10 @@
var loginName = [[${@permission.getPrincipalProperty('loginName')}]]; var loginName = [[${@permission.getPrincipalProperty('loginName')}]];
var prefix = ctx + "system/customerQuote"; var prefix = ctx + "system/customerQuote";
var commonCurrency = $("#commonCurrency_add option:selected").val(); var commonCurrency = $("#commonCurrency_add option:selected").val();
$("#form-customerQuote-add").validate({focusCleanup: true}); $("#form-customerQuote-add").validate(
{
focusCleanup: true}
);
function submitHandler() { function submitHandler() {
if ($.validate.form()) { if ($.validate.form()) {
var formData = $("#form-customerQuote-add").serializeArray(); var formData = $("#form-customerQuote-add").serializeArray();
@ -245,6 +227,9 @@
$(document).ready(function() { $(document).ready(function() {
// 初始化时默认加载客户编号列表 // 初始化时默认加载客户编号列表
loadCustomerIds(); loadCustomerIds();
//初始化美元汇率
loadLatestUsdTax();
}); });
// 假设的加载客户编号列表函数 // 假设的加载客户编号列表函数
function loadCustomerIds() { function loadCustomerIds() {
@ -344,7 +329,7 @@
return $.table.selectDictLabel(sysUnitClassDatas, value); return $.table.selectDictLabel(sysUnitClassDatas, value);
} }
}, },
{title: '半成品类型',field: 'processMethod',align: 'center', {title: '加工方式',field: 'processMethod',align: 'center',
formatter: function(value, row, index) { formatter: function(value, row, index) {
return $.table.selectDictLabel(processMethodDatas, value); return $.table.selectDictLabel(processMethodDatas, value);
} }
@ -376,8 +361,8 @@
} }
}, },
{title: '国内税率',field: 'countTax',align: 'center',}, // {title: '国内税率',field: 'countTax',align: 'center',},
{ title: '美元汇率',field: 'usdTax', align: 'center',}, // { title: '美元汇率',field: 'usdTax', align: 'center',},
{ title: '物料的不含税单价(RMB)', { title: '物料的不含税单价(RMB)',
field: 'materialNoRmb', field: 'materialNoRmb',
align: 'center', align: 'center',
@ -753,7 +738,7 @@
} }
if ($("#usdTax_add").val() == null || $("#usdTax_add").val() == '') { if ($("#usdTax_add").val() == null || $("#usdTax_add").val() == '') {
$.modal.alertWarning("请输入美元汇率"); $.modal.alertWarning("当前未配置美元汇率,请联系总经理");
return; return;
} }
@ -848,7 +833,19 @@
$.modal.open("最新报价历史", url); $.modal.open("最新报价历史", url);
} }
//from的最新美元汇率
function loadLatestUsdTax() {
var url = ctx + 'system/exchangeRate/getLatestUsdTax';
$.ajax({
type: 'GET', // 请求类型
url: url, // 后端接口URL
dataType: 'json', // 预期服务器返回的数据类型
success: function(data) {
console.log(data)
$("#usdTax_add").val(data.data);
}
});
}
</script> </script>

Loading…
Cancel
Save