parent
b227f87f6a
commit
97d578f1ec
11 changed files with 537 additions and 0 deletions
@ -0,0 +1,140 @@ |
||||
/** |
||||
* Author: Tom Shuo |
||||
*/ |
||||
package org.springblade.desk.basic.controller; |
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
||||
import com.baomidou.mybatisplus.core.metadata.IPage; |
||||
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; |
||||
import io.swagger.v3.oas.annotations.Operation; |
||||
import io.swagger.v3.oas.annotations.Parameter; |
||||
import io.swagger.v3.oas.annotations.tags.Tag; |
||||
import jakarta.servlet.http.HttpServletResponse; |
||||
import jakarta.validation.Valid; |
||||
import lombok.AllArgsConstructor; |
||||
import org.springblade.core.boot.ctrl.BladeController; |
||||
import org.springblade.core.excel.util.ExcelUtil; |
||||
import org.springblade.core.mp.support.Condition; |
||||
import org.springblade.core.mp.support.Query; |
||||
import org.springblade.core.secure.BladeUser; |
||||
import org.springblade.core.secure.annotation.IsAdmin; |
||||
import org.springblade.core.tool.api.R; |
||||
import org.springblade.core.tool.utils.DateUtil; |
||||
import org.springblade.core.tool.utils.Func; |
||||
import org.springblade.desk.basic.excel.gen.FormulaGenExcel; |
||||
import org.springblade.desk.basic.pojo.entity.Formula; |
||||
import org.springblade.desk.basic.pojo.vo.gen.FormulaGenVO; |
||||
import org.springblade.desk.basic.service.gen.IFormulaGenService; |
||||
import org.springblade.desk.basic.wrapper.gen.FormulaGenWrapper; |
||||
import org.springframework.web.bind.annotation.*; |
||||
|
||||
import java.util.List; |
||||
import java.util.Map; |
||||
|
||||
/** |
||||
* [计算公式] 控制器 |
||||
* |
||||
* @author Tom Shuo |
||||
* @since 2025-11-20 |
||||
*/ |
||||
@RestController |
||||
@AllArgsConstructor |
||||
@RequestMapping("/BA/Formula") |
||||
@Tag(name = "[计算公式]", description = "[计算公式]接口") |
||||
public class FormulaController extends BladeController { |
||||
|
||||
private final IFormulaGenService formulaGenService; |
||||
|
||||
/** |
||||
* [计算公式] 详情 |
||||
*/ |
||||
@GetMapping("/detail") |
||||
@ApiOperationSupport(order = 1) |
||||
@Operation(summary = "详情", description = "传入Formula") |
||||
public R<FormulaGenVO> detail(Formula formula) { |
||||
Formula detail = formulaGenService.getOne(Condition.getQueryWrapper(formula)); |
||||
return R.data(FormulaGenWrapper.build().entityVO(detail)); |
||||
} |
||||
|
||||
/** |
||||
* [计算公式] 分页 |
||||
*/ |
||||
@GetMapping("/list") |
||||
@ApiOperationSupport(order = 2) |
||||
@Operation(summary = "分页", description = "传入Formula") |
||||
public R<IPage<FormulaGenVO>> list(@Parameter(hidden = true) @RequestParam Map<String, Object> formula, |
||||
Query query) { |
||||
IPage<Formula> pages = formulaGenService.page(Condition.getPage(query), |
||||
Condition.getQueryWrapper(formula, Formula.class)); |
||||
return R.data(FormulaGenWrapper.build().pageVO(pages)); |
||||
} |
||||
|
||||
|
||||
/** |
||||
* [计算公式] 自定义分页 |
||||
*/ |
||||
@GetMapping("/page") |
||||
@ApiOperationSupport(order = 3) |
||||
@Operation(summary = "分页", description = "传入Formula") |
||||
public R<IPage<FormulaGenVO>> page(FormulaGenVO formula, Query query) { |
||||
IPage<FormulaGenVO> pages = formulaGenService.selectFormulaPage(Condition.getPage(query), formula); |
||||
return R.data(pages); |
||||
} |
||||
|
||||
/** |
||||
* [计算公式] 新增 |
||||
*/ |
||||
@PostMapping("/save") |
||||
@ApiOperationSupport(order = 4) |
||||
@Operation(summary = "新增", description = "传入Formula") |
||||
public R save(@Valid @RequestBody Formula formula) { |
||||
return R.status(formulaGenService.save(formula)); |
||||
} |
||||
|
||||
/** |
||||
* [计算公式] 修改 |
||||
*/ |
||||
@PostMapping("/update") |
||||
@ApiOperationSupport(order = 5) |
||||
@Operation(summary = "修改", description = "传入Formula") |
||||
public R update(@Valid @RequestBody Formula formula) { |
||||
return R.status(formulaGenService.updateById(formula)); |
||||
} |
||||
|
||||
/** |
||||
* [计算公式] 新增或修改 |
||||
*/ |
||||
@PostMapping("/submit") |
||||
@ApiOperationSupport(order = 6) |
||||
@Operation(summary = "新增或修改", description = "传入Formula") |
||||
public R submit(@Valid @RequestBody Formula formula) { |
||||
return R.status(formulaGenService.saveOrUpdate(formula)); |
||||
} |
||||
|
||||
/** |
||||
* [计算公式] 删除 |
||||
*/ |
||||
@PostMapping("/remove") |
||||
@ApiOperationSupport(order = 7) |
||||
@Operation(summary = "逻辑删除", description = "传入ids") |
||||
public R remove(@Parameter(description = "主键集合", required = true) @RequestParam String ids) { |
||||
return R.status(formulaGenService.deleteLogic(Func.toLongList(ids))); |
||||
} |
||||
|
||||
/** |
||||
* 导出数据 |
||||
*/ |
||||
@IsAdmin |
||||
@GetMapping("/export-excel") |
||||
@ApiOperationSupport(order = 8) |
||||
@Operation(summary = "导出数据", description = "传入Formula") |
||||
public void exportFormula(@Parameter(hidden = true) @RequestParam Map<String, Object> formula, BladeUser bladeUser, HttpServletResponse response) { |
||||
QueryWrapper<Formula> queryWrapper = Condition.getQueryWrapper(formula, Formula.class); |
||||
//if (!AuthUtil.isAdministrator()) {
|
||||
// queryWrapper.lambda().eq(Formula::getTenantId, bladeUser.getTenantId());
|
||||
//}
|
||||
//queryWrapper.lambda().eq(FormulaEntity::getIsDeleted, BladeConstant.DB_NOT_DELETED);
|
||||
List<FormulaGenExcel> list = formulaGenService.exportFormula(queryWrapper); |
||||
ExcelUtil.export(response, "[计算公式]数据" + DateUtil.time(), "[计算公式]数据表", list, FormulaGenExcel.class); |
||||
} |
||||
} |
||||
@ -0,0 +1,74 @@ |
||||
/** |
||||
* Author: Tom Shuo |
||||
*/ |
||||
package org.springblade.desk.basic.excel.gen; |
||||
|
||||
|
||||
import com.alibaba.excel.annotation.ExcelProperty; |
||||
import com.alibaba.excel.annotation.write.style.ColumnWidth; |
||||
import com.alibaba.excel.annotation.write.style.ContentRowHeight; |
||||
import com.alibaba.excel.annotation.write.style.HeadRowHeight; |
||||
import lombok.Data; |
||||
|
||||
import java.io.Serial; |
||||
import java.io.Serializable; |
||||
|
||||
|
||||
/** |
||||
* [计算公式] Excel实体类 |
||||
* |
||||
* @author Tom Shuo |
||||
* @since 2025-11-20 |
||||
*/ |
||||
@Data |
||||
@ColumnWidth(25) |
||||
@HeadRowHeight(20) |
||||
@ContentRowHeight(18) |
||||
public class FormulaGenExcel implements Serializable { |
||||
|
||||
@Serial |
||||
private static final long serialVersionUID = 1L; |
||||
|
||||
/** |
||||
* 编码 |
||||
*/ |
||||
@ColumnWidth(20) |
||||
@ExcelProperty("编码") |
||||
private String code; |
||||
/** |
||||
* [计算公式]类型:[1]:槽液加药量;[2]:槽液添加后理论值;[3]:; |
||||
*/ |
||||
@ColumnWidth(20) |
||||
@ExcelProperty("[计算公式]类型:[1]:槽液加药量;[2]:槽液添加后理论值;[3]:;") |
||||
private Long formulaType; |
||||
/** |
||||
* 公式名称 |
||||
*/ |
||||
@ColumnWidth(20) |
||||
@ExcelProperty("公式名称") |
||||
private String name; |
||||
/** |
||||
* 公式内容 |
||||
*/ |
||||
@ColumnWidth(20) |
||||
@ExcelProperty("公式内容") |
||||
private String content; |
||||
/** |
||||
* 计算表达式 |
||||
*/ |
||||
@ColumnWidth(20) |
||||
@ExcelProperty("计算表达式") |
||||
private String expression; |
||||
/** |
||||
* 排序 |
||||
*/ |
||||
@ColumnWidth(20) |
||||
@ExcelProperty("排序") |
||||
private Long sort; |
||||
/** |
||||
* 备注 |
||||
*/ |
||||
@ColumnWidth(20) |
||||
@ExcelProperty("备注") |
||||
private String remark; |
||||
} |
||||
@ -0,0 +1,40 @@ |
||||
/** |
||||
* Author: Tom Shuo |
||||
*/ |
||||
package org.springblade.desk.basic.mapper.gen; |
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.Wrapper; |
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
||||
import com.baomidou.mybatisplus.core.metadata.IPage; |
||||
import org.apache.ibatis.annotations.Param; |
||||
import org.springblade.desk.basic.excel.gen.FormulaGenExcel; |
||||
import org.springblade.desk.basic.pojo.entity.Formula; |
||||
import org.springblade.desk.basic.pojo.vo.gen.FormulaGenVO; |
||||
|
||||
import java.util.List; |
||||
|
||||
/** |
||||
* [计算公式] Mapper 接口 |
||||
* |
||||
* @author Tom Shuo |
||||
* @since 2025-11-20 |
||||
*/ |
||||
public interface FormulaGenMapper extends BaseMapper<Formula> { |
||||
|
||||
/** |
||||
* 自定义分页 |
||||
* |
||||
* @param page 分页参数 |
||||
* @param formula 查询参数 |
||||
* @return List<FormulaVO> |
||||
*/ |
||||
List<FormulaGenVO> selectFormulaPage(IPage page, FormulaGenVO formula); |
||||
|
||||
/** |
||||
* 获取导出数据 |
||||
* |
||||
* @param queryWrapper 查询条件 |
||||
* @return List<FormulaExcel> |
||||
*/ |
||||
List<FormulaGenExcel> exportFormula(@Param("ew") Wrapper<Formula> queryWrapper); |
||||
} |
||||
@ -0,0 +1,24 @@ |
||||
<?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="org.springblade.desk.basic.mapper.gen.FormulaGenMapper"> |
||||
|
||||
<!-- 通用查询映射结果 --> |
||||
<resultMap id="formulaResultMap" type="org.springblade.desk.basic.pojo.entity.Formula"> |
||||
<result column="CODE" property="code"/> |
||||
<result column="FORMULA_TYPE" property="formulaType"/> |
||||
<result column="NAME" property="name"/> |
||||
<result column="CONTENT" property="content"/> |
||||
<result column="EXPRESSION" property="expression"/> |
||||
<result column="SORT" property="sort"/> |
||||
<result column="REMARK" property="remark"/> |
||||
</resultMap> |
||||
|
||||
<select id="selectFormulaPage" resultMap="formulaResultMap"> |
||||
SELECT * FROM BA_FORMULA WHERE is_deleted = 0 |
||||
</select> |
||||
|
||||
<select id="exportFormula" resultType="org.springblade.desk.basic.excel.gen.FormulaGenExcel"> |
||||
SELECT * FROM BA_FORMULA ${ew.customSqlSegment} |
||||
</select> |
||||
|
||||
</mapper> |
||||
@ -0,0 +1,4 @@ |
||||
/** |
||||
* 基础数据 |
||||
*/ |
||||
package org.springblade.desk.basic; |
||||
@ -0,0 +1,24 @@ |
||||
/** |
||||
* Author: Tom Shuo |
||||
*/ |
||||
package org.springblade.desk.basic.pojo.dto.gen; |
||||
|
||||
import lombok.Data; |
||||
import lombok.EqualsAndHashCode; |
||||
import org.springblade.desk.basic.pojo.entity.Formula; |
||||
|
||||
import java.io.Serial; |
||||
|
||||
/** |
||||
* [计算公式] 数据传输对象实体类 |
||||
* |
||||
* @author Tom Shuo |
||||
* @since 2025-11-20 |
||||
*/ |
||||
@Data |
||||
@EqualsAndHashCode(callSuper = true) |
||||
public class FormulaGenDTO extends Formula { |
||||
@Serial |
||||
private static final long serialVersionUID = 1L; |
||||
|
||||
} |
||||
@ -0,0 +1,93 @@ |
||||
/** |
||||
* Author: Tom Shuo |
||||
*/ |
||||
package org.springblade.desk.basic.pojo.entity; |
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableName; |
||||
import io.swagger.v3.oas.annotations.media.Schema; |
||||
import lombok.Data; |
||||
import lombok.EqualsAndHashCode; |
||||
import org.springblade.core.mp.base.BaseEntity; |
||||
|
||||
import java.io.Serial; |
||||
|
||||
/** |
||||
* [计算公式] 实体类 |
||||
* |
||||
* @author Tom Shuo |
||||
* @since 2025-11-20 |
||||
*/ |
||||
@Data |
||||
@TableName("BA_FORMULA") |
||||
@Schema(description = "Formula Entity对象") |
||||
@EqualsAndHashCode(callSuper = true) |
||||
public class Formula extends BaseEntity { |
||||
|
||||
@Serial |
||||
private static final long serialVersionUID = 1L; |
||||
|
||||
/** |
||||
* 编码 |
||||
*/ |
||||
public static final String COL_CODE = "CODE"; |
||||
/** |
||||
* [计算公式]类型:[1]:槽液加药量;[2]:槽液添加后理论值;[3]:; |
||||
*/ |
||||
public static final String COL_FORMULA_TYPE = "FORMULA_TYPE"; |
||||
/** |
||||
* 公式名称 |
||||
*/ |
||||
public static final String COL_NAME = "NAME"; |
||||
/** |
||||
* 公式内容 |
||||
*/ |
||||
public static final String COL_CONTENT = "CONTENT"; |
||||
/** |
||||
* 计算表达式 |
||||
*/ |
||||
public static final String COL_EXPRESSION = "EXPRESSION"; |
||||
/** |
||||
* 排序 |
||||
*/ |
||||
public static final String COL_SORT = "SORT"; |
||||
/** |
||||
* 备注 |
||||
*/ |
||||
public static final String COL_REMARK = "REMARK"; |
||||
|
||||
/** |
||||
* 编码 |
||||
*/ |
||||
@Schema(description = "编码") |
||||
private String code; |
||||
/** |
||||
* [计算公式]类型:[1]:槽液加药量;[2]:槽液添加后理论值;[3]:; |
||||
*/ |
||||
@Schema(description = "[计算公式]类型:[1]:槽液加药量;[2]:槽液添加后理论值;[3]:;") |
||||
private Long formulaType; |
||||
/** |
||||
* 公式名称 |
||||
*/ |
||||
@Schema(description = "公式名称") |
||||
private String name; |
||||
/** |
||||
* 公式内容 |
||||
*/ |
||||
@Schema(description = "公式内容") |
||||
private String content; |
||||
/** |
||||
* 计算表达式 |
||||
*/ |
||||
@Schema(description = "计算表达式") |
||||
private String expression; |
||||
/** |
||||
* 排序 |
||||
*/ |
||||
@Schema(description = "排序") |
||||
private Long sort; |
||||
/** |
||||
* 备注 |
||||
*/ |
||||
@Schema(description = "备注") |
||||
private String remark; |
||||
} |
||||
@ -0,0 +1,24 @@ |
||||
/** |
||||
* Author: Tom Shuo |
||||
*/ |
||||
package org.springblade.desk.basic.pojo.vo.gen; |
||||
|
||||
import lombok.Data; |
||||
import lombok.EqualsAndHashCode; |
||||
import org.springblade.desk.basic.pojo.entity.Formula; |
||||
|
||||
import java.io.Serial; |
||||
|
||||
/** |
||||
* [计算公式] 视图实体类 |
||||
* |
||||
* @author Tom Shuo |
||||
* @since 2025-11-20 |
||||
*/ |
||||
@Data |
||||
@EqualsAndHashCode(callSuper = true) |
||||
public class FormulaGenVO extends Formula { |
||||
@Serial |
||||
private static final long serialVersionUID = 1L; |
||||
|
||||
} |
||||
@ -0,0 +1,38 @@ |
||||
/** |
||||
* Author: Tom Shuo |
||||
*/ |
||||
package org.springblade.desk.basic.service.gen; |
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.Wrapper; |
||||
import com.baomidou.mybatisplus.core.metadata.IPage; |
||||
import org.springblade.core.mp.base.BaseService; |
||||
import org.springblade.desk.basic.excel.gen.FormulaGenExcel; |
||||
import org.springblade.desk.basic.pojo.entity.Formula; |
||||
import org.springblade.desk.basic.pojo.vo.gen.FormulaGenVO; |
||||
|
||||
import java.util.List; |
||||
|
||||
/** |
||||
* [计算公式] 服务类 |
||||
* |
||||
* @author Tom Shuo |
||||
* @since 2025-11-20 |
||||
*/ |
||||
public interface IFormulaGenService extends BaseService<Formula> { |
||||
/** |
||||
* 自定义分页 |
||||
* |
||||
* @param page 分页参数 |
||||
* @param formula 查询参数 |
||||
* @return IPage<FormulaVO> |
||||
*/ |
||||
IPage<FormulaGenVO> selectFormulaPage(IPage<FormulaGenVO> page, FormulaGenVO formula); |
||||
|
||||
/** |
||||
* 导出数据 |
||||
* |
||||
* @param queryWrapper 查询条件 |
||||
* @return List<FormulaExcel> |
||||
*/ |
||||
List<FormulaGenExcel> exportFormula(Wrapper<Formula> queryWrapper); |
||||
} |
||||
@ -0,0 +1,40 @@ |
||||
/** |
||||
* Author: Tom Shuo |
||||
*/ |
||||
package org.springblade.desk.basic.service.impl.gen; |
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.Wrapper; |
||||
import com.baomidou.mybatisplus.core.metadata.IPage; |
||||
import org.springblade.core.mp.base.BaseServiceImpl; |
||||
import org.springblade.desk.basic.excel.gen.FormulaGenExcel; |
||||
import org.springblade.desk.basic.mapper.gen.FormulaGenMapper; |
||||
import org.springblade.desk.basic.pojo.entity.Formula; |
||||
import org.springblade.desk.basic.pojo.vo.gen.FormulaGenVO; |
||||
import org.springblade.desk.basic.service.gen.IFormulaGenService; |
||||
import org.springframework.stereotype.Service; |
||||
|
||||
import java.util.List; |
||||
|
||||
/** |
||||
* [计算公式] 服务实现类 |
||||
* |
||||
* @author Tom Shuo |
||||
* @since 2025-11-20 |
||||
*/ |
||||
@Service |
||||
public class FormulaGenServiceImpl extends BaseServiceImpl<FormulaGenMapper, Formula> implements IFormulaGenService { |
||||
|
||||
@Override |
||||
public IPage<FormulaGenVO> selectFormulaPage(IPage<FormulaGenVO> page, FormulaGenVO formula) { |
||||
return page.setRecords(baseMapper.selectFormulaPage(page, formula)); |
||||
} |
||||
|
||||
@Override |
||||
public List<FormulaGenExcel> exportFormula(Wrapper<Formula> queryWrapper) { |
||||
List<FormulaGenExcel> formulaList = baseMapper.exportFormula(queryWrapper); |
||||
//formulaList.forEach(formula -> {
|
||||
// formula.setTypeName(DictCache.getValue(DictEnum.YES_NO, Formula.getType()));
|
||||
//});
|
||||
return formulaList; |
||||
} |
||||
} |
||||
@ -0,0 +1,36 @@ |
||||
/** |
||||
* Author: Tom Shuo |
||||
*/ |
||||
package org.springblade.desk.basic.wrapper.gen; |
||||
|
||||
import org.springblade.core.mp.support.BaseEntityWrapper; |
||||
import org.springblade.core.tool.utils.BeanUtil; |
||||
import org.springblade.desk.basic.pojo.entity.Formula; |
||||
import org.springblade.desk.basic.pojo.vo.gen.FormulaGenVO; |
||||
|
||||
import java.util.Objects; |
||||
|
||||
/** |
||||
* [计算公式] 包装类,返回视图层所需的字段 |
||||
* |
||||
* @author Tom Shuo |
||||
* @since 2025-11-20 |
||||
*/ |
||||
public class FormulaGenWrapper extends BaseEntityWrapper<Formula, FormulaGenVO> { |
||||
|
||||
public static FormulaGenWrapper build() { |
||||
return new FormulaGenWrapper(); |
||||
} |
||||
|
||||
@Override |
||||
public FormulaGenVO entityVO(Formula formula) { |
||||
FormulaGenVO formulaVO = Objects.requireNonNull(BeanUtil.copyProperties(formula, FormulaGenVO.class)); |
||||
|
||||
//User createUser = UserCache.getUser(formula.getCreateUser());
|
||||
//User updateUser = UserCache.getUser(formula.getUpdateUser());
|
||||
//formulaVO.setCreateUserName(createUser.getName());
|
||||
//formulaVO.setUpdateUserName(updateUser.getName());
|
||||
|
||||
return formulaVO; |
||||
} |
||||
} |
||||
Loading…
Reference in new issue