diff --git a/ruoyi-admin/src/main/java/com/ruoyi/system/controller/BaseExchangeRateController.java b/ruoyi-admin/src/main/java/com/ruoyi/system/controller/BaseExchangeRateController.java new file mode 100644 index 00000000..a6ce83ad --- /dev/null +++ b/ruoyi-admin/src/main/java/com/ruoyi/system/controller/BaseExchangeRateController.java @@ -0,0 +1,151 @@ +package com.ruoyi.system.controller; + +import java.util.List; +import org.apache.shiro.authz.annotation.RequiresPermissions; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Controller; +import org.springframework.ui.ModelMap; +import org.springframework.web.bind.annotation.GetMapping; +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.enums.BusinessType; +import com.ruoyi.system.domain.BaseExchangeRate; +import com.ruoyi.system.service.IBaseExchangeRateService; +import com.ruoyi.common.core.controller.BaseController; +import com.ruoyi.common.core.domain.AjaxResult; +import com.ruoyi.common.utils.poi.ExcelUtil; +import com.ruoyi.common.core.page.TableDataInfo; + +/** + * 基础资料汇率管理Controller + * + * @author 刘晓旭 + * @date 2024-10-29 + */ +@Controller +@RequestMapping("/system/exchangeRate") +public class BaseExchangeRateController extends BaseController +{ + private String prefix = "system/exchangeRate"; + + @Autowired + private IBaseExchangeRateService baseExchangeRateService; + + @RequiresPermissions("system:exchangeRate:view") + @GetMapping() + public String exchangeRate() + { + return prefix + "/exchangeRate"; + } + + /** + * 查询基础资料汇率管理列表 + */ + @RequiresPermissions("system:exchangeRate:list") + @PostMapping("/list") + @ResponseBody + public TableDataInfo list(BaseExchangeRate baseExchangeRate) + { + startPage(); + List list = baseExchangeRateService.selectBaseExchangeRateList(baseExchangeRate); + return getDataTable(list); + } + + /** + * 导出基础资料汇率管理列表 + */ + @RequiresPermissions("system:exchangeRate:export") + @Log(title = "基础资料汇率管理", businessType = BusinessType.EXPORT) + @PostMapping("/export") + @ResponseBody + public AjaxResult export(BaseExchangeRate baseExchangeRate) + { + List list = baseExchangeRateService.selectBaseExchangeRateList(baseExchangeRate); + ExcelUtil util = new ExcelUtil(BaseExchangeRate.class); + return util.exportExcel(list, "基础资料汇率管理数据"); + } + + /** + * 新增基础资料汇率管理 + */ + @GetMapping("/add") + public String add() + { + return prefix + "/add"; + } + + /** + * 新增保存基础资料汇率管理 + */ + @RequiresPermissions("system:exchangeRate:add") + @Log(title = "基础资料汇率管理", businessType = BusinessType.INSERT) + @PostMapping("/add") + @ResponseBody + public AjaxResult addSave(BaseExchangeRate baseExchangeRate) + { + return toAjax(baseExchangeRateService.insertBaseExchangeRate(baseExchangeRate)); + } + + /** + * 修改基础资料汇率管理 + */ + @GetMapping("/edit/{exchangeRateId}") + public String edit(@PathVariable("exchangeRateId") Long exchangeRateId, ModelMap mmap) + { + BaseExchangeRate baseExchangeRate = baseExchangeRateService.selectBaseExchangeRateById(exchangeRateId); + mmap.put("baseExchangeRate", baseExchangeRate); + return prefix + "/edit"; + } + + /** + * 修改保存基础资料汇率管理 + */ + @RequiresPermissions("system:exchangeRate:edit") + @Log(title = "基础资料汇率管理", businessType = BusinessType.UPDATE) + @PostMapping("/edit") + @ResponseBody + public AjaxResult editSave(BaseExchangeRate baseExchangeRate) + { + return toAjax(baseExchangeRateService.updateBaseExchangeRate(baseExchangeRate)); + } + + /** + * 删除基础资料汇率管理 + */ + @RequiresPermissions("system:exchangeRate:remove") + @Log(title = "基础资料汇率管理", businessType = BusinessType.DELETE) + @PostMapping( "/remove") + @ResponseBody + public AjaxResult remove(String ids) + { + return toAjax(baseExchangeRateService.deleteBaseExchangeRateByIds(ids)); + } + + /** + * 作废基础资料汇率管理 + */ + @RequiresPermissions("system:exchangeRate:cancel") + @Log(title = "基础资料汇率管理", businessType = BusinessType.CANCEL) + @GetMapping( "/cancel/{id}") + @ResponseBody + public AjaxResult cancel(@PathVariable("id") Long id){ + return toAjax(baseExchangeRateService.cancelBaseExchangeRateById(id)); + } + + /** + * 恢复基础资料汇率管理 + */ + @RequiresPermissions("system:exchangeRate:restore") + @Log(title = "基础资料汇率管理", businessType = BusinessType.RESTORE) + @GetMapping( "/restore/{id}") + @ResponseBody + public AjaxResult restore(@PathVariable("id")Long id) + { + return toAjax(baseExchangeRateService.restoreBaseExchangeRateById(id)); + } + + +} 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 new file mode 100644 index 00000000..adbaff08 --- /dev/null +++ b/ruoyi-admin/src/main/java/com/ruoyi/system/domain/BaseExchangeRate.java @@ -0,0 +1,89 @@ +package com.ruoyi.system.domain; + +import java.math.BigDecimal; +import java.util.Date; +import com.fasterxml.jackson.annotation.JsonFormat; +import org.apache.commons.lang3.builder.ToStringBuilder; +import org.apache.commons.lang3.builder.ToStringStyle; +import com.ruoyi.common.annotation.Excel; +import com.ruoyi.common.core.domain.BaseEntity; + +/** + * 基础资料汇率管理对象 base_exchange_rate + * + * @author 刘晓旭 + * @date 2024-10-29 + */ +public class BaseExchangeRate extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + /** 汇率ID */ + private Long exchangeRateId; + + /** 汇率 */ + @Excel(name = "汇率") + private BigDecimal exchangeRate; + + /** 开始时间 */ + @JsonFormat(pattern = "yyyy-MM-dd") + @Excel(name = "开始时间", width = 30, dateFormat = "yyyy-MM-dd") + private Date startTime; + + /** 结束时间 */ + @JsonFormat(pattern = "yyyy-MM-dd") + @Excel(name = "结束时间", width = 30, dateFormat = "yyyy-MM-dd") + private Date endTime; + + public void setExchangeRateId(Long exchangeRateId) + { + this.exchangeRateId = exchangeRateId; + } + + public Long getExchangeRateId() + { + return exchangeRateId; + } + public void setExchangeRate(BigDecimal exchangeRate) + { + this.exchangeRate = exchangeRate; + } + + public BigDecimal getExchangeRate() + { + return exchangeRate; + } + public void setStartTime(Date startTime) + { + this.startTime = startTime; + } + + public Date getStartTime() + { + return startTime; + } + public void setEndTime(Date endTime) + { + this.endTime = endTime; + } + + public Date getEndTime() + { + return endTime; + } + + @Override + public String toString() { + return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) + .append("exchangeRateId", getExchangeRateId()) + .append("exchangeRate", getExchangeRate()) + .append("startTime", getStartTime()) + .append("endTime", getEndTime()) + .append("createBy", getCreateBy()) + .append("createTime", getCreateTime()) + .append("updateBy", getUpdateBy()) + .append("updateTime", getUpdateTime()) + .append("remark", getRemark()) + .toString(); + } +} 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 new file mode 100644 index 00000000..1a369057 --- /dev/null +++ b/ruoyi-admin/src/main/java/com/ruoyi/system/mapper/BaseExchangeRateMapper.java @@ -0,0 +1,86 @@ +package com.ruoyi.system.mapper; + +import java.util.List; +import com.ruoyi.system.domain.BaseExchangeRate; + +/** + * 基础资料汇率管理Mapper接口 + * + * @author 刘晓旭 + * @date 2024-10-29 + */ +public interface BaseExchangeRateMapper +{ + /** + * 查询基础资料汇率管理 + * + * @param exchangeRateId 基础资料汇率管理ID + * @return 基础资料汇率管理 + */ + public BaseExchangeRate selectBaseExchangeRateById(Long exchangeRateId); + + /** + * 查询基础资料汇率管理列表 + * + * @param baseExchangeRate 基础资料汇率管理 + * @return 基础资料汇率管理集合 + */ + public List selectBaseExchangeRateList(BaseExchangeRate baseExchangeRate); + + + /** + * 查询时间交叉 + * + * @param baseExchangeRate 基础资料汇率管理 + * @return 基础资料汇率管理集合 + */ + public List selectExchangeRateByTimeRange(BaseExchangeRate baseExchangeRate); + + /** + * 新增基础资料汇率管理 + * + * @param baseExchangeRate 基础资料汇率管理 + * @return 结果 + */ + public int insertBaseExchangeRate(BaseExchangeRate baseExchangeRate); + + /** + * 修改基础资料汇率管理 + * + * @param baseExchangeRate 基础资料汇率管理 + * @return 结果 + */ + public int updateBaseExchangeRate(BaseExchangeRate baseExchangeRate); + + /** + * 删除基础资料汇率管理 + * + * @param exchangeRateId 基础资料汇率管理ID + * @return 结果 + */ + public int deleteBaseExchangeRateById(Long exchangeRateId); + + /** + * 批量删除基础资料汇率管理 + * + * @param exchangeRateIds 需要删除的数据ID + * @return 结果 + */ + public int deleteBaseExchangeRateByIds(String[] exchangeRateIds); + + /** + * 作废基础资料汇率管理 + * + * @param exchangeRateId 基础资料汇率管理ID + * @return 结果 + */ + public int cancelBaseExchangeRateById(Long exchangeRateId); + + /** + * 恢复基础资料汇率管理 + * + * @param exchangeRateId 基础资料汇率管理ID + * @return 结果 + */ + public int restoreBaseExchangeRateById(Long exchangeRateId); +} diff --git a/ruoyi-admin/src/main/java/com/ruoyi/system/service/IBaseExchangeRateService.java b/ruoyi-admin/src/main/java/com/ruoyi/system/service/IBaseExchangeRateService.java new file mode 100644 index 00000000..4974fd33 --- /dev/null +++ b/ruoyi-admin/src/main/java/com/ruoyi/system/service/IBaseExchangeRateService.java @@ -0,0 +1,75 @@ +package com.ruoyi.system.service; + +import java.util.List; +import com.ruoyi.system.domain.BaseExchangeRate; + +/** + * 基础资料汇率管理Service接口 + * + * @author 刘晓旭 + * @date 2024-10-29 + */ +public interface IBaseExchangeRateService +{ + /** + * 查询基础资料汇率管理 + * + * @param exchangeRateId 基础资料汇率管理ID + * @return 基础资料汇率管理 + */ + public BaseExchangeRate selectBaseExchangeRateById(Long exchangeRateId); + + /** + * 查询基础资料汇率管理列表 + * + * @param baseExchangeRate 基础资料汇率管理 + * @return 基础资料汇率管理集合 + */ + public List selectBaseExchangeRateList(BaseExchangeRate baseExchangeRate); + + /** + * 新增基础资料汇率管理 + * + * @param baseExchangeRate 基础资料汇率管理 + * @return 结果 + */ + public int insertBaseExchangeRate(BaseExchangeRate baseExchangeRate); + + /** + * 修改基础资料汇率管理 + * + * @param baseExchangeRate 基础资料汇率管理 + * @return 结果 + */ + public int updateBaseExchangeRate(BaseExchangeRate baseExchangeRate); + + /** + * 批量删除基础资料汇率管理 + * + * @param ids 需要删除的数据ID + * @return 结果 + */ + public int deleteBaseExchangeRateByIds(String ids); + + /** + * 删除基础资料汇率管理信息 + * + * @param exchangeRateId 基础资料汇率管理ID + * @return 结果 + */ + public int deleteBaseExchangeRateById(Long exchangeRateId); + + /** + * 作废基础资料汇率管理 + * @param exchangeRateId 基础资料汇率管理ID + * @return + */ + int cancelBaseExchangeRateById(Long exchangeRateId); + + /** + * 恢复基础资料汇率管理 + * @param exchangeRateId 基础资料汇率管理ID + * @return + */ + 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 new file mode 100644 index 00000000..7dd0dacd --- /dev/null +++ b/ruoyi-admin/src/main/java/com/ruoyi/system/service/impl/BaseExchangeRateServiceImpl.java @@ -0,0 +1,143 @@ +package com.ruoyi.system.service.impl; + +import java.util.Date; +import java.util.List; + +import com.ruoyi.common.exception.BusinessException; +import com.ruoyi.common.utils.DateUtils; +import com.ruoyi.common.utils.ShiroUtils; +import com.ruoyi.system.service.ISysDiffLogService; +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.util.CollectionUtils; + +/** + * 基础资料汇率管理Service业务层处理 + * + * @author 刘晓旭 + * @date 2024-10-29 + */ +@Service +public class BaseExchangeRateServiceImpl implements IBaseExchangeRateService +{ + @Autowired + private BaseExchangeRateMapper baseExchangeRateMapper; + + + /** + * 查询基础资料汇率管理 + * + * @param exchangeRateId 基础资料汇率管理ID + * @return 基础资料汇率管理 + */ + @Override + public BaseExchangeRate selectBaseExchangeRateById(Long exchangeRateId) + { + return baseExchangeRateMapper.selectBaseExchangeRateById(exchangeRateId); + } + + /** + * 查询基础资料汇率管理列表 + * + * @param baseExchangeRate 基础资料汇率管理 + * @return 基础资料汇率管理 + */ + @Override + public List selectBaseExchangeRateList(BaseExchangeRate baseExchangeRate) + { + return baseExchangeRateMapper.selectBaseExchangeRateList(baseExchangeRate); + } + + /** + * 新增基础资料汇率管理 + * + * @param baseExchangeRate 基础资料汇率管理 + * @return 结果 + */ + @Override + public int insertBaseExchangeRate(BaseExchangeRate baseExchangeRate) + { + String loginName = ShiroUtils.getLoginName(); + baseExchangeRate.setCreateBy(loginName); + baseExchangeRate.setCreateTime(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("新增汇率失败!该时间段内已存在汇率数据!"); + } + return baseExchangeRateMapper.insertBaseExchangeRate(baseExchangeRate); + } + + /** + * 修改基础资料汇率管理 + * + * @param baseExchangeRate 基础资料汇率管理 + * @return 结果 + */ + @Override + public int updateBaseExchangeRate(BaseExchangeRate baseExchangeRate) + { + String loginName = ShiroUtils.getLoginName(); + baseExchangeRate.setUpdateBy(loginName); + baseExchangeRate.setUpdateTime(DateUtils.getNowDate()); + return baseExchangeRateMapper.updateBaseExchangeRate(baseExchangeRate); + } + + /** + * 删除基础资料汇率管理对象 + * + * @param ids 需要删除的数据ID + * @return 结果 + */ + @Override + public int deleteBaseExchangeRateByIds(String ids) + { + return baseExchangeRateMapper.deleteBaseExchangeRateByIds(Convert.toStrArray(ids)); + } + + /** + * 删除基础资料汇率管理信息 + * + * @param exchangeRateId 基础资料汇率管理ID + * @return 结果 + */ + @Override + public int deleteBaseExchangeRateById(Long exchangeRateId) + { + return baseExchangeRateMapper.deleteBaseExchangeRateById(exchangeRateId); + } + + /** + * 作废基础资料汇率管理 + * + * @param exchangeRateId 基础资料汇率管理ID + * @return 结果 + */ + @Override + public int cancelBaseExchangeRateById(Long exchangeRateId) + { + return baseExchangeRateMapper.cancelBaseExchangeRateById(exchangeRateId); + } + + /** + * 恢复基础资料汇率管理信息 + * + * @param exchangeRateId 基础资料汇率管理ID + * @return 结果 + */ + @Override + public int restoreBaseExchangeRateById(Long exchangeRateId) + { + return baseExchangeRateMapper.restoreBaseExchangeRateById(exchangeRateId); + } +} diff --git a/ruoyi-admin/src/main/resources/mapper/system/BaseExchangeRateMapper.xml b/ruoyi-admin/src/main/resources/mapper/system/BaseExchangeRateMapper.xml new file mode 100644 index 00000000..2147e1cf --- /dev/null +++ b/ruoyi-admin/src/main/resources/mapper/system/BaseExchangeRateMapper.xml @@ -0,0 +1,100 @@ + + + + + + + + + + + + + + + + + + select exchange_rate_id, exchange_rate, start_time, end_time, create_by, create_time, update_by, update_time, remark from base_exchange_rate + + + + + + + + + + + insert into base_exchange_rate + + exchange_rate, + start_time, + end_time, + create_by, + create_time, + update_by, + update_time, + remark, + + + #{exchangeRate}, + #{startTime}, + #{endTime}, + #{createBy}, + #{createTime}, + #{updateBy}, + #{updateTime}, + #{remark}, + + + + + update base_exchange_rate + + exchange_rate = #{exchangeRate}, + start_time = #{startTime}, + end_time = #{endTime}, + create_by = #{createBy}, + create_time = #{createTime}, + update_by = #{updateBy}, + update_time = #{updateTime}, + remark = #{remark}, + + where exchange_rate_id = #{exchangeRateId} + + + + delete from base_exchange_rate where exchange_rate_id = #{exchangeRateId} + + + + delete from base_exchange_rate where exchange_rate_id in + + #{exchangeRateId} + + + + + update base_exchange_rate set del_flag = '1' where exchange_rate_id = #{exchangeRateId} + + + + update base_exchange_rate set del_flag = '0' where exchange_rate_id = #{exchangeRateId} + + + \ No newline at end of file diff --git a/ruoyi-admin/src/main/resources/templates/system/exchangeRate/add.html b/ruoyi-admin/src/main/resources/templates/system/exchangeRate/add.html new file mode 100644 index 00000000..7aae6e7f --- /dev/null +++ b/ruoyi-admin/src/main/resources/templates/system/exchangeRate/add.html @@ -0,0 +1,69 @@ + + + + + + + +
+
+
+ +
+
+ + +
+
+
+
+ +
+
+ + +
+
+
+
+ +
+ +
+
+ + + + + + +
+
+ + + + + \ No newline at end of file diff --git a/ruoyi-admin/src/main/resources/templates/system/exchangeRate/edit.html b/ruoyi-admin/src/main/resources/templates/system/exchangeRate/edit.html new file mode 100644 index 00000000..be6b1f4e --- /dev/null +++ b/ruoyi-admin/src/main/resources/templates/system/exchangeRate/edit.html @@ -0,0 +1,70 @@ + + + + + + + +
+
+ +
+ +
+
+ + +
+
+
+
+ +
+
+ + +
+
+
+
+ +
+ +
+
+ + + + + + +
+
+ + + + + \ No newline at end of file diff --git a/ruoyi-admin/src/main/resources/templates/system/exchangeRate/exchangeRate.html b/ruoyi-admin/src/main/resources/templates/system/exchangeRate/exchangeRate.html new file mode 100644 index 00000000..2a122a2b --- /dev/null +++ b/ruoyi-admin/src/main/resources/templates/system/exchangeRate/exchangeRate.html @@ -0,0 +1,101 @@ + + + + + + +
+
+
+
+
+ +
+
+
+ + +
+
+
+
+
+ + + + \ No newline at end of file