后台添加单位转换模块
This commit is contained in:
parent
c65933eb06
commit
0fd33d7631
@ -68,14 +68,15 @@ spring:
|
|||||||
data:
|
data:
|
||||||
# redis 配置
|
# redis 配置
|
||||||
redis:
|
redis:
|
||||||
# host: ngtools.cn
|
host: ngtools.cn
|
||||||
host: 10.75.166.165
|
#host: 10.75.166.165
|
||||||
# 端口,默认为6379
|
# 端口,默认为6379
|
||||||
port: 6379
|
port: 6379
|
||||||
# 数据库索引
|
# 数据库索引
|
||||||
database: 0
|
database: 0
|
||||||
# 密码
|
# 密码
|
||||||
password: Cxc@2024!1121
|
#password: Cxc@2024!1121
|
||||||
|
password: 4877017Ldy
|
||||||
# 连接超时时间
|
# 连接超时时间
|
||||||
timeout: 10s
|
timeout: 10s
|
||||||
lettuce:
|
lettuce:
|
||||||
|
|||||||
@ -0,0 +1,104 @@
|
|||||||
|
package com.ruoyi.system.controller;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import jakarta.servlet.http.HttpServletResponse;
|
||||||
|
import org.springframework.security.access.prepost.PreAuthorize;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
|
import org.springframework.web.bind.annotation.PutMapping;
|
||||||
|
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||||
|
import org.springframework.web.bind.annotation.PathVariable;
|
||||||
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
import com.ruoyi.common.annotation.Log;
|
||||||
|
import com.ruoyi.common.core.controller.BaseController;
|
||||||
|
import com.ruoyi.common.core.domain.AjaxResult;
|
||||||
|
import com.ruoyi.common.enums.BusinessType;
|
||||||
|
import com.ruoyi.system.domain.SysUnitConvert;
|
||||||
|
import com.ruoyi.system.service.ISysUnitConvertService;
|
||||||
|
import com.ruoyi.common.utils.poi.ExcelUtil;
|
||||||
|
import com.ruoyi.common.core.page.TableDataInfo;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 【请填写功能名称】Controller
|
||||||
|
*
|
||||||
|
* @author ruoyi
|
||||||
|
* @date 2026-01-17
|
||||||
|
*/
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/system/convert")
|
||||||
|
public class SysUnitConvertController extends BaseController
|
||||||
|
{
|
||||||
|
@Autowired
|
||||||
|
private ISysUnitConvertService sysUnitConvertService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询【请填写功能名称】列表
|
||||||
|
*/
|
||||||
|
@PreAuthorize("@ss.hasPermi('system:convert:list')")
|
||||||
|
@GetMapping("/list")
|
||||||
|
public TableDataInfo list(SysUnitConvert sysUnitConvert)
|
||||||
|
{
|
||||||
|
startPage();
|
||||||
|
List<SysUnitConvert> list = sysUnitConvertService.selectSysUnitConvertList(sysUnitConvert);
|
||||||
|
return getDataTable(list);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 导出【请填写功能名称】列表
|
||||||
|
*/
|
||||||
|
@PreAuthorize("@ss.hasPermi('system:convert:export')")
|
||||||
|
@Log(title = "【请填写功能名称】", businessType = BusinessType.EXPORT)
|
||||||
|
@PostMapping("/export")
|
||||||
|
public void export(HttpServletResponse response, SysUnitConvert sysUnitConvert)
|
||||||
|
{
|
||||||
|
List<SysUnitConvert> list = sysUnitConvertService.selectSysUnitConvertList(sysUnitConvert);
|
||||||
|
ExcelUtil<SysUnitConvert> util = new ExcelUtil<SysUnitConvert>(SysUnitConvert.class);
|
||||||
|
util.exportExcel(response, list, "【请填写功能名称】数据");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取【请填写功能名称】详细信息
|
||||||
|
*/
|
||||||
|
@PreAuthorize("@ss.hasPermi('system:convert:query')")
|
||||||
|
@GetMapping(value = "/{id}")
|
||||||
|
public AjaxResult getInfo(@PathVariable("id") Long id)
|
||||||
|
{
|
||||||
|
return success(sysUnitConvertService.selectSysUnitConvertById(id));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 新增【请填写功能名称】
|
||||||
|
*/
|
||||||
|
@PreAuthorize("@ss.hasPermi('system:convert:add')")
|
||||||
|
@Log(title = "【请填写功能名称】", businessType = BusinessType.INSERT)
|
||||||
|
@PostMapping
|
||||||
|
public AjaxResult add(@RequestBody SysUnitConvert sysUnitConvert)
|
||||||
|
{
|
||||||
|
return toAjax(sysUnitConvertService.insertSysUnitConvert(sysUnitConvert));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改【请填写功能名称】
|
||||||
|
*/
|
||||||
|
@PreAuthorize("@ss.hasPermi('system:convert:edit')")
|
||||||
|
@Log(title = "【请填写功能名称】", businessType = BusinessType.UPDATE)
|
||||||
|
@PutMapping
|
||||||
|
public AjaxResult edit(@RequestBody SysUnitConvert sysUnitConvert)
|
||||||
|
{
|
||||||
|
return toAjax(sysUnitConvertService.updateSysUnitConvert(sysUnitConvert));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除【请填写功能名称】
|
||||||
|
*/
|
||||||
|
@PreAuthorize("@ss.hasPermi('system:convert:remove')")
|
||||||
|
@Log(title = "【请填写功能名称】", businessType = BusinessType.DELETE)
|
||||||
|
@DeleteMapping("/{ids}")
|
||||||
|
public AjaxResult remove(@PathVariable Long[] ids)
|
||||||
|
{
|
||||||
|
return toAjax(sysUnitConvertService.deleteSysUnitConvertByIds(ids));
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,90 @@
|
|||||||
|
package com.ruoyi.system.controller;
|
||||||
|
|
||||||
|
|
||||||
|
import com.ruoyi.system.domain.SysUnitConvert;
|
||||||
|
import com.ruoyi.system.service.ISysUnitConvertService;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import java.math.RoundingMode;
|
||||||
|
|
||||||
|
@Component
|
||||||
|
public class UnitConvert {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private ISysUnitConvertService sysUnitConvertService;
|
||||||
|
|
||||||
|
public double ConvertUniter(String unitType, double oldValue, int oldUnit, int newUnit) {
|
||||||
|
// 查询旧单位信息
|
||||||
|
if ("temperature".equalsIgnoreCase(unitType)) {
|
||||||
|
return handleTemperatureConversion(BigDecimal.valueOf(oldValue), (long) oldUnit, (long) newUnit).doubleValue();
|
||||||
|
} else {
|
||||||
|
|
||||||
|
SysUnitConvert oldUnitInfo =sysUnitConvertService.selectSysUnitConvertUnitByTypeOrder(unitType, (long) oldUnit,null);
|
||||||
|
if (oldUnitInfo == null) {
|
||||||
|
throw new IllegalArgumentException("旧单位 '" + oldUnit + "' 不存在或不可用");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
SysUnitConvert baseUnitInfo = sysUnitConvertService.selectSysUnitConvertUnitByTypeOrder (unitType,null,"Y");
|
||||||
|
if (baseUnitInfo == null) {
|
||||||
|
throw new IllegalArgumentException("基准单位 不存在或不可用");
|
||||||
|
}
|
||||||
|
|
||||||
|
// 查询新单位信息
|
||||||
|
SysUnitConvert newUnitInfo = sysUnitConvertService.selectSysUnitConvertUnitByTypeOrder(unitType, (long) newUnit,null);
|
||||||
|
if (newUnitInfo == null) {
|
||||||
|
throw new IllegalArgumentException("新单位 '" + newUnit + "' 不存在或不可用");
|
||||||
|
}
|
||||||
|
|
||||||
|
BigDecimal oldFactor = oldUnitInfo.getConversionFactor();
|
||||||
|
BigDecimal newFactor = newUnitInfo.getConversionFactor();
|
||||||
|
|
||||||
|
// 检查旧单位转换因子是否为零
|
||||||
|
if (oldFactor.compareTo(BigDecimal.ZERO) == 0) {
|
||||||
|
throw new ArithmeticException("旧单位 '" + oldUnit + "' 的转换因子为零,无法进行转换");
|
||||||
|
}
|
||||||
|
|
||||||
|
// 计算基准值:oldValue / oldFactor
|
||||||
|
int scale = 20; // 设置足够大的精度以避免精度丢失
|
||||||
|
BigDecimal baseValue = BigDecimal.valueOf(oldValue).divide(oldFactor, scale, RoundingMode.HALF_UP);
|
||||||
|
|
||||||
|
// 计算新值:baseValue * newFactor
|
||||||
|
BigDecimal newValue = baseValue.multiply(newFactor);
|
||||||
|
|
||||||
|
// 四舍五入到合理的小数位数(例如10位)
|
||||||
|
newValue = newValue.setScale(10, RoundingMode.HALF_UP);
|
||||||
|
|
||||||
|
return newValue.doubleValue();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 温度转换方法
|
||||||
|
public static BigDecimal handleTemperatureConversion(BigDecimal oldValue, Long oldUnit, Long newUnit) {
|
||||||
|
final BigDecimal THIRTY_TWO = BigDecimal.valueOf(32);
|
||||||
|
final BigDecimal FIVE = BigDecimal.valueOf(5);
|
||||||
|
final BigDecimal NINE = BigDecimal.valueOf(9);
|
||||||
|
final BigDecimal TWO_HUNDRED_SEVENTY_THREE_POINT_ONE_FIVE = BigDecimal.valueOf(273.15);
|
||||||
|
// 使用原始值计算
|
||||||
|
BigDecimal celsius;
|
||||||
|
if (oldUnit == 0) {
|
||||||
|
celsius = oldValue;
|
||||||
|
} else if (oldUnit == 1) {
|
||||||
|
celsius = oldValue.subtract(THIRTY_TWO).multiply(FIVE).divide(NINE, 10, RoundingMode.HALF_UP);
|
||||||
|
} else if (oldUnit == 2) {
|
||||||
|
celsius = oldValue.subtract(TWO_HUNDRED_SEVENTY_THREE_POINT_ONE_FIVE);
|
||||||
|
} else {
|
||||||
|
throw new IllegalArgumentException("无效温度单位");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (newUnit == 0) {
|
||||||
|
return celsius;
|
||||||
|
} else if (newUnit == 1) {
|
||||||
|
return celsius.multiply(NINE).divide(FIVE, 10, RoundingMode.HALF_UP).add(THIRTY_TWO);
|
||||||
|
} else if (newUnit == 2) {
|
||||||
|
return celsius.add(TWO_HUNDRED_SEVENTY_THREE_POINT_ONE_FIVE);
|
||||||
|
}
|
||||||
|
throw new IllegalArgumentException("无效温度单位");
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,143 @@
|
|||||||
|
package com.ruoyi.system.domain;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
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;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 【请填写功能名称】对象 sys_unit_convert
|
||||||
|
*
|
||||||
|
* @author ruoyi
|
||||||
|
* @date 2026-01-17
|
||||||
|
*/
|
||||||
|
public class SysUnitConvert extends BaseEntity
|
||||||
|
{
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
/** $column.columnComment */
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
/** 单位类型 */
|
||||||
|
@Excel(name = "单位类型")
|
||||||
|
private String unitType;
|
||||||
|
|
||||||
|
/** 单位名称 */
|
||||||
|
@Excel(name = "单位名称")
|
||||||
|
private String unitName;
|
||||||
|
|
||||||
|
/** 是否基准 */
|
||||||
|
@Excel(name = "是否基准")
|
||||||
|
private String baseUnit;
|
||||||
|
|
||||||
|
/** 换算因子 */
|
||||||
|
@Excel(name = "换算因子")
|
||||||
|
private BigDecimal conversionFactor;
|
||||||
|
|
||||||
|
/** 类型名称 */
|
||||||
|
@Excel(name = "类型名称")
|
||||||
|
private String unitTypeName;
|
||||||
|
|
||||||
|
/** 状态 */
|
||||||
|
@Excel(name = "状态")
|
||||||
|
private String status;
|
||||||
|
|
||||||
|
/** 单位序号 */
|
||||||
|
@Excel(name = "单位序号")
|
||||||
|
private Long unitOrder;
|
||||||
|
|
||||||
|
public void setId(Long id)
|
||||||
|
{
|
||||||
|
this.id = id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Long getId()
|
||||||
|
{
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setUnitType(String unitType)
|
||||||
|
{
|
||||||
|
this.unitType = unitType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getUnitType()
|
||||||
|
{
|
||||||
|
return unitType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setUnitName(String unitName)
|
||||||
|
{
|
||||||
|
this.unitName = unitName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getUnitName()
|
||||||
|
{
|
||||||
|
return unitName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setBaseUnit(String baseUnit)
|
||||||
|
{
|
||||||
|
this.baseUnit = baseUnit;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getBaseUnit()
|
||||||
|
{
|
||||||
|
return baseUnit;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setConversionFactor(BigDecimal conversionFactor)
|
||||||
|
{
|
||||||
|
this.conversionFactor = conversionFactor;
|
||||||
|
}
|
||||||
|
|
||||||
|
public BigDecimal getConversionFactor()
|
||||||
|
{
|
||||||
|
return conversionFactor;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setUnitTypeName(String unitTypeName)
|
||||||
|
{
|
||||||
|
this.unitTypeName = unitTypeName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getUnitTypeName()
|
||||||
|
{
|
||||||
|
return unitTypeName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setStatus(String status)
|
||||||
|
{
|
||||||
|
this.status = status;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getStatus()
|
||||||
|
{
|
||||||
|
return status;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setUnitOrder(Long unitOrder)
|
||||||
|
{
|
||||||
|
this.unitOrder = unitOrder;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Long getUnitOrder()
|
||||||
|
{
|
||||||
|
return unitOrder;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
|
||||||
|
.append("id", getId())
|
||||||
|
.append("unitType", getUnitType())
|
||||||
|
.append("unitName", getUnitName())
|
||||||
|
.append("baseUnit", getBaseUnit())
|
||||||
|
.append("conversionFactor", getConversionFactor())
|
||||||
|
.append("unitTypeName", getUnitTypeName())
|
||||||
|
.append("status", getStatus())
|
||||||
|
.append("unitOrder", getUnitOrder())
|
||||||
|
.toString();
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,77 @@
|
|||||||
|
package com.ruoyi.system.mapper;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import com.ruoyi.system.domain.SysUnitConvert;
|
||||||
|
import org.apache.ibatis.annotations.Param;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 【请填写功能名称】Mapper接口
|
||||||
|
*
|
||||||
|
* @author ruoyi
|
||||||
|
* @date 2026-01-17
|
||||||
|
*/
|
||||||
|
public interface SysUnitConvertMapper
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* 查询【请填写功能名称】
|
||||||
|
*
|
||||||
|
* @param id 【请填写功能名称】主键
|
||||||
|
* @return 【请填写功能名称】
|
||||||
|
*/
|
||||||
|
public SysUnitConvert selectSysUnitConvertById(Long id);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询【请填写功能名称】列表
|
||||||
|
*
|
||||||
|
* @param sysUnitConvert 【请填写功能名称】
|
||||||
|
* @return 【请填写功能名称】集合
|
||||||
|
*/
|
||||||
|
public List<SysUnitConvert> selectSysUnitConvertList(SysUnitConvert sysUnitConvert);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 新增【请填写功能名称】
|
||||||
|
*
|
||||||
|
* @param sysUnitConvert 【请填写功能名称】
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
public int insertSysUnitConvert(SysUnitConvert sysUnitConvert);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改【请填写功能名称】
|
||||||
|
*
|
||||||
|
* @param sysUnitConvert 【请填写功能名称】
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
public int updateSysUnitConvert(SysUnitConvert sysUnitConvert);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除【请填写功能名称】
|
||||||
|
*
|
||||||
|
* @param id 【请填写功能名称】主键
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
public int deleteSysUnitConvertById(Long id);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 批量删除【请填写功能名称】
|
||||||
|
*
|
||||||
|
* @param ids 需要删除的数据主键集合
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
public int deleteSysUnitConvertByIds(Long[] ids);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询单位换算
|
||||||
|
*
|
||||||
|
* @param unitType 单位换算
|
||||||
|
* @param unitOrder 单位换算
|
||||||
|
* @param baseUnit 单位换算
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
public SysUnitConvert selectSysUnitConvertUnitByTypeOrder(
|
||||||
|
@Param("unitType") String unitType,
|
||||||
|
@Param("unitOrder") Long unitOrder, // 修正参数类型
|
||||||
|
@Param("baseUnit") String baseUnit
|
||||||
|
);
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,73 @@
|
|||||||
|
package com.ruoyi.system.service;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import com.ruoyi.system.domain.SysUnitConvert;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 【请填写功能名称】Service接口
|
||||||
|
*
|
||||||
|
* @author ruoyi
|
||||||
|
* @date 2026-01-17
|
||||||
|
*/
|
||||||
|
public interface ISysUnitConvertService
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* 查询【请填写功能名称】
|
||||||
|
*
|
||||||
|
* @param id 【请填写功能名称】主键
|
||||||
|
* @return 【请填写功能名称】
|
||||||
|
*/
|
||||||
|
public SysUnitConvert selectSysUnitConvertById(Long id);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询【请填写功能名称】列表
|
||||||
|
*
|
||||||
|
* @param sysUnitConvert 【请填写功能名称】
|
||||||
|
* @return 【请填写功能名称】集合
|
||||||
|
*/
|
||||||
|
public List<SysUnitConvert> selectSysUnitConvertList(SysUnitConvert sysUnitConvert);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 新增【请填写功能名称】
|
||||||
|
*
|
||||||
|
* @param sysUnitConvert 【请填写功能名称】
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
public int insertSysUnitConvert(SysUnitConvert sysUnitConvert);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改【请填写功能名称】
|
||||||
|
*
|
||||||
|
* @param sysUnitConvert 【请填写功能名称】
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
public int updateSysUnitConvert(SysUnitConvert sysUnitConvert);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 批量删除【请填写功能名称】
|
||||||
|
*
|
||||||
|
* @param ids 需要删除的【请填写功能名称】主键集合
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
public int deleteSysUnitConvertByIds(Long[] ids);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除【请填写功能名称】信息
|
||||||
|
*
|
||||||
|
* @param id 【请填写功能名称】主键
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
public int deleteSysUnitConvertById(Long id);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询单位
|
||||||
|
*
|
||||||
|
* @param unitType 单位换算
|
||||||
|
* @param unitOrder 单位换算
|
||||||
|
* @param baseUnit 单位换算
|
||||||
|
* @return 单位换算集合
|
||||||
|
*/
|
||||||
|
public SysUnitConvert selectSysUnitConvertUnitByTypeOrder(String unitType,Long unitOrder, String baseUnit);
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,108 @@
|
|||||||
|
package com.ruoyi.system.service.impl;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
import com.ruoyi.system.mapper.SysUnitConvertMapper;
|
||||||
|
import com.ruoyi.system.domain.SysUnitConvert;
|
||||||
|
import com.ruoyi.system.service.ISysUnitConvertService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 【请填写功能名称】Service业务层处理
|
||||||
|
*
|
||||||
|
* @author ruoyi
|
||||||
|
* @date 2026-01-17
|
||||||
|
*/
|
||||||
|
@Service
|
||||||
|
public class SysUnitConvertServiceImpl implements ISysUnitConvertService
|
||||||
|
{
|
||||||
|
@Autowired
|
||||||
|
private SysUnitConvertMapper sysUnitConvertMapper;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询【请填写功能名称】
|
||||||
|
*
|
||||||
|
* @param id 【请填写功能名称】主键
|
||||||
|
* @return 【请填写功能名称】
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public SysUnitConvert selectSysUnitConvertById(Long id)
|
||||||
|
{
|
||||||
|
return sysUnitConvertMapper.selectSysUnitConvertById(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询【请填写功能名称】列表
|
||||||
|
*
|
||||||
|
* @param sysUnitConvert 【请填写功能名称】
|
||||||
|
* @return 【请填写功能名称】
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public List<SysUnitConvert> selectSysUnitConvertList(SysUnitConvert sysUnitConvert)
|
||||||
|
{
|
||||||
|
return sysUnitConvertMapper.selectSysUnitConvertList(sysUnitConvert);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 新增【请填写功能名称】
|
||||||
|
*
|
||||||
|
* @param sysUnitConvert 【请填写功能名称】
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public int insertSysUnitConvert(SysUnitConvert sysUnitConvert)
|
||||||
|
{
|
||||||
|
return sysUnitConvertMapper.insertSysUnitConvert(sysUnitConvert);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改【请填写功能名称】
|
||||||
|
*
|
||||||
|
* @param sysUnitConvert 【请填写功能名称】
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public int updateSysUnitConvert(SysUnitConvert sysUnitConvert)
|
||||||
|
{
|
||||||
|
return sysUnitConvertMapper.updateSysUnitConvert(sysUnitConvert);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 批量删除【请填写功能名称】
|
||||||
|
*
|
||||||
|
* @param ids 需要删除的【请填写功能名称】主键
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public int deleteSysUnitConvertByIds(Long[] ids)
|
||||||
|
{
|
||||||
|
return sysUnitConvertMapper.deleteSysUnitConvertByIds(ids);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除【请填写功能名称】信息
|
||||||
|
*
|
||||||
|
* @param id 【请填写功能名称】主键
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public int deleteSysUnitConvertById(Long id)
|
||||||
|
{
|
||||||
|
return sysUnitConvertMapper.deleteSysUnitConvertById(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询单位换算
|
||||||
|
* @param unitType 单位换算
|
||||||
|
* @param unitOrder 单位换算
|
||||||
|
* @param baseUnit 单位换算
|
||||||
|
* @return 单位换算
|
||||||
|
*/
|
||||||
|
|
||||||
|
@Override
|
||||||
|
|
||||||
|
public SysUnitConvert selectSysUnitConvertUnitByTypeOrder(String unitType,Long unitOrder, String baseUnit) {
|
||||||
|
return sysUnitConvertMapper.selectSysUnitConvertUnitByTypeOrder(unitType, unitOrder,baseUnit);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,86 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8" ?>
|
||||||
|
<!DOCTYPE mapper
|
||||||
|
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
|
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||||
|
<mapper namespace="com.ruoyi.system.mapper.SysUnitConvertMapper">
|
||||||
|
|
||||||
|
<resultMap type="SysUnitConvert" id="SysUnitConvertResult">
|
||||||
|
<result property="id" column="id" />
|
||||||
|
<result property="unitType" column="unit_type" />
|
||||||
|
<result property="unitName" column="unit_name" />
|
||||||
|
<result property="baseUnit" column="base_unit" />
|
||||||
|
<result property="conversionFactor" column="conversion_factor" />
|
||||||
|
<result property="unitTypeName" column="unit_type_name" />
|
||||||
|
<result property="status" column="status" />
|
||||||
|
<result property="unitOrder" column="unit_order" />
|
||||||
|
</resultMap>
|
||||||
|
|
||||||
|
<sql id="selectSysUnitConvertVo">
|
||||||
|
select id, unit_type, unit_name, base_unit, conversion_factor, unit_type_name, status, unit_order from sys_unit_convert
|
||||||
|
</sql>
|
||||||
|
|
||||||
|
<select id="selectSysUnitConvertList" parameterType="SysUnitConvert" resultMap="SysUnitConvertResult">
|
||||||
|
<include refid="selectSysUnitConvertVo"/>
|
||||||
|
<where>
|
||||||
|
<if test="unitType != null and unitType != ''"> and unit_type = #{unitType}</if>
|
||||||
|
<if test="unitName != null and unitName != ''"> and unit_name like concat('%', #{unitName}, '%')</if>
|
||||||
|
<if test="baseUnit != null and baseUnit != ''"> and base_unit = #{baseUnit}</if>
|
||||||
|
<if test="conversionFactor != null "> and conversion_factor = #{conversionFactor}</if>
|
||||||
|
<if test="unitTypeName != null and unitTypeName != ''"> and unit_type_name like concat('%', #{unitTypeName}, '%')</if>
|
||||||
|
<if test="status != null and status != ''"> and status = #{status}</if>
|
||||||
|
<if test="unitOrder != null "> and unit_order = #{unitOrder}</if>
|
||||||
|
</where>
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<select id="selectSysUnitConvertById" parameterType="Long" resultMap="SysUnitConvertResult">
|
||||||
|
<include refid="selectSysUnitConvertVo"/>
|
||||||
|
where id = #{id}
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<insert id="insertSysUnitConvert" parameterType="SysUnitConvert" useGeneratedKeys="true" keyProperty="id">
|
||||||
|
insert into sys_unit_convert
|
||||||
|
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||||
|
<if test="unitType != null and unitType != ''">unit_type,</if>
|
||||||
|
<if test="unitName != null and unitName != ''">unit_name,</if>
|
||||||
|
<if test="baseUnit != null">base_unit,</if>
|
||||||
|
<if test="conversionFactor != null">conversion_factor,</if>
|
||||||
|
<if test="unitTypeName != null and unitTypeName != ''">unit_type_name,</if>
|
||||||
|
<if test="status != null">status,</if>
|
||||||
|
<if test="unitOrder != null">unit_order,</if>
|
||||||
|
</trim>
|
||||||
|
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||||
|
<if test="unitType != null and unitType != ''">#{unitType},</if>
|
||||||
|
<if test="unitName != null and unitName != ''">#{unitName},</if>
|
||||||
|
<if test="baseUnit != null">#{baseUnit},</if>
|
||||||
|
<if test="conversionFactor != null">#{conversionFactor},</if>
|
||||||
|
<if test="unitTypeName != null and unitTypeName != ''">#{unitTypeName},</if>
|
||||||
|
<if test="status != null">#{status},</if>
|
||||||
|
<if test="unitOrder != null">#{unitOrder},</if>
|
||||||
|
</trim>
|
||||||
|
</insert>
|
||||||
|
|
||||||
|
<update id="updateSysUnitConvert" parameterType="SysUnitConvert">
|
||||||
|
update sys_unit_convert
|
||||||
|
<trim prefix="SET" suffixOverrides=",">
|
||||||
|
<if test="unitType != null and unitType != ''">unit_type = #{unitType},</if>
|
||||||
|
<if test="unitName != null and unitName != ''">unit_name = #{unitName},</if>
|
||||||
|
<if test="baseUnit != null">base_unit = #{baseUnit},</if>
|
||||||
|
<if test="conversionFactor != null">conversion_factor = #{conversionFactor},</if>
|
||||||
|
<if test="unitTypeName != null and unitTypeName != ''">unit_type_name = #{unitTypeName},</if>
|
||||||
|
<if test="status != null">status = #{status},</if>
|
||||||
|
<if test="unitOrder != null">unit_order = #{unitOrder},</if>
|
||||||
|
</trim>
|
||||||
|
where id = #{id}
|
||||||
|
</update>
|
||||||
|
|
||||||
|
<delete id="deleteSysUnitConvertById" parameterType="Long">
|
||||||
|
delete from sys_unit_convert where id = #{id}
|
||||||
|
</delete>
|
||||||
|
|
||||||
|
<delete id="deleteSysUnitConvertByIds" parameterType="String">
|
||||||
|
delete from sys_unit_convert where id in
|
||||||
|
<foreach item="id" collection="array" open="(" separator="," close=")">
|
||||||
|
#{id}
|
||||||
|
</foreach>
|
||||||
|
</delete>
|
||||||
|
</mapper>
|
||||||
Loading…
Reference in New Issue
Block a user