feat(pltcm): 添加钢种分类管理功能
- 创建了钢种分类实体类 TdbSteelgrade 包含钢种名、冲压级别、屈服强度等字段 - 定义了业务对象 TdbSteelgradeBo 和视图对象 TdbSteelgradeVo - 实现了钢种分类的增删改查服务接口 ITdbSteelgradeService - 开发了钢种分类控制器 TdbSteelgradeController 提供 REST API 接口 - 配置了 MyBatis Plus 映射器和 XML 映射文件 - 实现了分页查询、导出 Excel、批量删除等功能 - 添加了数据验证和业务逻辑处理
This commit is contained in:
@@ -0,0 +1,98 @@
|
|||||||
|
package com.klp.pltcm.controller;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
import javax.validation.constraints.*;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
import org.springframework.validation.annotation.Validated;
|
||||||
|
import com.klp.common.annotation.RepeatSubmit;
|
||||||
|
import com.klp.common.annotation.Log;
|
||||||
|
import com.klp.common.core.controller.BaseController;
|
||||||
|
import com.klp.common.core.domain.PageQuery;
|
||||||
|
import com.klp.common.core.domain.R;
|
||||||
|
import com.klp.common.core.validate.AddGroup;
|
||||||
|
import com.klp.common.core.validate.EditGroup;
|
||||||
|
import com.klp.common.enums.BusinessType;
|
||||||
|
import com.klp.common.utils.poi.ExcelUtil;
|
||||||
|
import com.klp.pltcm.domain.vo.TdbSteelgradeVo;
|
||||||
|
import com.klp.pltcm.domain.bo.TdbSteelgradeBo;
|
||||||
|
import com.klp.pltcm.service.ITdbSteelgradeService;
|
||||||
|
import com.klp.common.core.page.TableDataInfo;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 钢种分类
|
||||||
|
*
|
||||||
|
* @author klp
|
||||||
|
* @date 2026-07-06
|
||||||
|
*/
|
||||||
|
@Validated
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/pltcm/steelgrade")
|
||||||
|
public class TdbSteelgradeController extends BaseController {
|
||||||
|
|
||||||
|
private final ITdbSteelgradeService iTdbSteelgradeService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询钢种分类列表
|
||||||
|
*/
|
||||||
|
@GetMapping("/list")
|
||||||
|
public TableDataInfo<TdbSteelgradeVo> list(TdbSteelgradeBo bo, PageQuery pageQuery) {
|
||||||
|
return iTdbSteelgradeService.queryPageList(bo, pageQuery);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 导出钢种分类列表
|
||||||
|
*/
|
||||||
|
@Log(title = "钢种分类", businessType = BusinessType.EXPORT)
|
||||||
|
@PostMapping("/export")
|
||||||
|
public void export(TdbSteelgradeBo bo, HttpServletResponse response) {
|
||||||
|
List<TdbSteelgradeVo> list = iTdbSteelgradeService.queryList(bo);
|
||||||
|
ExcelUtil.exportExcel(list, "钢种分类", TdbSteelgradeVo.class, response);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取钢种分类详细信息
|
||||||
|
*
|
||||||
|
* @param steelGrade 钢种名(主键)
|
||||||
|
*/
|
||||||
|
@GetMapping("/{steelGrade}")
|
||||||
|
public R<TdbSteelgradeVo> getInfo(@NotBlank(message = "钢种名不能为空")
|
||||||
|
@PathVariable String steelGrade) {
|
||||||
|
return R.ok(iTdbSteelgradeService.queryById(steelGrade));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 新增钢种分类
|
||||||
|
*/
|
||||||
|
@Log(title = "钢种分类", businessType = BusinessType.INSERT)
|
||||||
|
@RepeatSubmit()
|
||||||
|
@PostMapping()
|
||||||
|
public R<Void> add(@Validated(AddGroup.class) @RequestBody TdbSteelgradeBo bo) {
|
||||||
|
return toAjax(iTdbSteelgradeService.insertByBo(bo));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改钢种分类
|
||||||
|
*/
|
||||||
|
@Log(title = "钢种分类", businessType = BusinessType.UPDATE)
|
||||||
|
@RepeatSubmit()
|
||||||
|
@PutMapping()
|
||||||
|
public R<Void> edit(@Validated(EditGroup.class) @RequestBody TdbSteelgradeBo bo) {
|
||||||
|
return toAjax(iTdbSteelgradeService.updateByBo(bo));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除钢种分类
|
||||||
|
*
|
||||||
|
* @param steelGrades 钢种名串
|
||||||
|
*/
|
||||||
|
@Log(title = "钢种分类", businessType = BusinessType.DELETE)
|
||||||
|
@DeleteMapping("/{steelGrades}")
|
||||||
|
public R<Void> remove(@NotEmpty(message = "钢种名不能为空")
|
||||||
|
@PathVariable String[] steelGrades) {
|
||||||
|
return toAjax(iTdbSteelgradeService.deleteWithValidByIds(java.util.Arrays.asList(steelGrades), true));
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,65 @@
|
|||||||
|
package com.klp.pltcm.domain;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.*;
|
||||||
|
import com.klp.common.core.domain.BaseEntity;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 钢种分类 tdb_steelgrade
|
||||||
|
*
|
||||||
|
* @author klp
|
||||||
|
* @date 2026-07-06
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@EqualsAndHashCode(callSuper = true)
|
||||||
|
@TableName("tdb_steelgrade")
|
||||||
|
public class TdbSteelgrade extends BaseEntity {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 钢种名
|
||||||
|
*/
|
||||||
|
@TableId(value = "steel_grade", type = IdType.INPUT)
|
||||||
|
private String steelGrade;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 冲压级别
|
||||||
|
*/
|
||||||
|
private String drawingGrade;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 屈服强度
|
||||||
|
*/
|
||||||
|
private BigDecimal yieldStress;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 屈服等级
|
||||||
|
*/
|
||||||
|
private BigDecimal yieldClass;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 录入日期
|
||||||
|
*/
|
||||||
|
private Date insDate;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 内容/备注
|
||||||
|
*/
|
||||||
|
private String content;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 焊接代码
|
||||||
|
*/
|
||||||
|
private Long weldCode;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除标志(0正常 1删除)
|
||||||
|
*/
|
||||||
|
@TableLogic
|
||||||
|
private Long delFlag;
|
||||||
|
}
|
||||||
@@ -0,0 +1,54 @@
|
|||||||
|
package com.klp.pltcm.domain.bo;
|
||||||
|
|
||||||
|
import com.klp.common.core.domain.BaseEntity;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 钢种分类业务对象 tdb_steelgrade
|
||||||
|
*
|
||||||
|
* @author klp
|
||||||
|
* @date 2026-07-06
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@EqualsAndHashCode(callSuper = true)
|
||||||
|
public class TdbSteelgradeBo extends BaseEntity {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 钢种名
|
||||||
|
*/
|
||||||
|
private String steelGrade;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 冲压级别
|
||||||
|
*/
|
||||||
|
private String drawingGrade;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 屈服强度
|
||||||
|
*/
|
||||||
|
private BigDecimal yieldStress;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 屈服等级
|
||||||
|
*/
|
||||||
|
private BigDecimal yieldClass;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 录入日期
|
||||||
|
*/
|
||||||
|
private Date insDate;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 内容/备注
|
||||||
|
*/
|
||||||
|
private String content;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 焊接代码
|
||||||
|
*/
|
||||||
|
private Long weldCode;
|
||||||
|
}
|
||||||
@@ -0,0 +1,48 @@
|
|||||||
|
package com.klp.pltcm.domain.vo;
|
||||||
|
|
||||||
|
import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
|
||||||
|
import com.alibaba.excel.annotation.ExcelProperty;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 钢种分类视图对象 tdb_steelgrade
|
||||||
|
*
|
||||||
|
* @author klp
|
||||||
|
* @date 2026-07-06
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@ExcelIgnoreUnannotated
|
||||||
|
public class TdbSteelgradeVo {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
@ExcelProperty(value = "钢种名")
|
||||||
|
private String steelGrade;
|
||||||
|
|
||||||
|
@ExcelProperty(value = "冲压级别")
|
||||||
|
private String drawingGrade;
|
||||||
|
|
||||||
|
@ExcelProperty(value = "屈服强度")
|
||||||
|
private BigDecimal yieldStress;
|
||||||
|
|
||||||
|
@ExcelProperty(value = "屈服等级")
|
||||||
|
private BigDecimal yieldClass;
|
||||||
|
|
||||||
|
@ExcelProperty(value = "录入日期")
|
||||||
|
private Date insDate;
|
||||||
|
|
||||||
|
@ExcelProperty(value = "内容/备注")
|
||||||
|
private String content;
|
||||||
|
|
||||||
|
@ExcelProperty(value = "焊接代码")
|
||||||
|
private Long weldCode;
|
||||||
|
|
||||||
|
@ExcelProperty(value = "创建时间")
|
||||||
|
private Date createTime;
|
||||||
|
|
||||||
|
@ExcelProperty(value = "更新时间")
|
||||||
|
private Date updateTime;
|
||||||
|
}
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
package com.klp.pltcm.mapper;
|
||||||
|
|
||||||
|
import com.klp.pltcm.domain.TdbSteelgrade;
|
||||||
|
import com.klp.pltcm.domain.vo.TdbSteelgradeVo;
|
||||||
|
import com.klp.common.core.mapper.BaseMapperPlus;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 钢种分类Mapper接口
|
||||||
|
*
|
||||||
|
* @author klp
|
||||||
|
* @date 2026-07-06
|
||||||
|
*/
|
||||||
|
public interface TdbSteelgradeMapper extends BaseMapperPlus<TdbSteelgradeMapper, TdbSteelgrade, TdbSteelgradeVo> {
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,48 @@
|
|||||||
|
package com.klp.pltcm.service;
|
||||||
|
|
||||||
|
import com.klp.pltcm.domain.vo.TdbSteelgradeVo;
|
||||||
|
import com.klp.pltcm.domain.bo.TdbSteelgradeBo;
|
||||||
|
import com.klp.common.core.page.TableDataInfo;
|
||||||
|
import com.klp.common.core.domain.PageQuery;
|
||||||
|
|
||||||
|
import java.util.Collection;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 钢种分类Service接口
|
||||||
|
*
|
||||||
|
* @author klp
|
||||||
|
* @date 2026-07-06
|
||||||
|
*/
|
||||||
|
public interface ITdbSteelgradeService {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询钢种分类
|
||||||
|
*/
|
||||||
|
TdbSteelgradeVo queryById(String steelGrade);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询钢种分类列表
|
||||||
|
*/
|
||||||
|
TableDataInfo<TdbSteelgradeVo> queryPageList(TdbSteelgradeBo bo, PageQuery pageQuery);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询钢种分类列表
|
||||||
|
*/
|
||||||
|
List<TdbSteelgradeVo> queryList(TdbSteelgradeBo bo);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 新增钢种分类
|
||||||
|
*/
|
||||||
|
Boolean insertByBo(TdbSteelgradeBo bo);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改钢种分类
|
||||||
|
*/
|
||||||
|
Boolean updateByBo(TdbSteelgradeBo bo);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 校验并批量删除钢种分类信息
|
||||||
|
*/
|
||||||
|
Boolean deleteWithValidByIds(Collection<String> ids, Boolean isValid);
|
||||||
|
}
|
||||||
@@ -0,0 +1,87 @@
|
|||||||
|
package com.klp.pltcm.service.impl;
|
||||||
|
|
||||||
|
import cn.hutool.core.bean.BeanUtil;
|
||||||
|
import com.klp.common.core.page.TableDataInfo;
|
||||||
|
import com.klp.common.core.domain.PageQuery;
|
||||||
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||||
|
import com.klp.common.utils.StringUtils;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
import com.klp.pltcm.domain.bo.TdbSteelgradeBo;
|
||||||
|
import com.klp.pltcm.domain.vo.TdbSteelgradeVo;
|
||||||
|
import com.klp.pltcm.domain.TdbSteelgrade;
|
||||||
|
import com.klp.pltcm.mapper.TdbSteelgradeMapper;
|
||||||
|
import com.klp.pltcm.service.ITdbSteelgradeService;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Collection;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 钢种分类Service业务层处理
|
||||||
|
*
|
||||||
|
* @author klp
|
||||||
|
* @date 2026-07-06
|
||||||
|
*/
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
@Service
|
||||||
|
public class TdbSteelgradeServiceImpl implements ITdbSteelgradeService {
|
||||||
|
|
||||||
|
private final TdbSteelgradeMapper baseMapper;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public TdbSteelgradeVo queryById(String steelGrade) {
|
||||||
|
return baseMapper.selectVoById(steelGrade);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public TableDataInfo<TdbSteelgradeVo> queryPageList(TdbSteelgradeBo bo, PageQuery pageQuery) {
|
||||||
|
LambdaQueryWrapper<TdbSteelgrade> lqw = buildQueryWrapper(bo);
|
||||||
|
Page<TdbSteelgradeVo> result = baseMapper.selectVoPage(pageQuery.build(), lqw);
|
||||||
|
return TableDataInfo.build(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<TdbSteelgradeVo> queryList(TdbSteelgradeBo bo) {
|
||||||
|
LambdaQueryWrapper<TdbSteelgrade> lqw = buildQueryWrapper(bo);
|
||||||
|
return baseMapper.selectVoList(lqw);
|
||||||
|
}
|
||||||
|
|
||||||
|
private LambdaQueryWrapper<TdbSteelgrade> buildQueryWrapper(TdbSteelgradeBo bo) {
|
||||||
|
Map<String, Object> params = bo.getParams();
|
||||||
|
LambdaQueryWrapper<TdbSteelgrade> lqw = Wrappers.lambdaQuery();
|
||||||
|
lqw.like(StringUtils.isNotBlank(bo.getSteelGrade()), TdbSteelgrade::getSteelGrade, bo.getSteelGrade());
|
||||||
|
lqw.eq(StringUtils.isNotBlank(bo.getDrawingGrade()), TdbSteelgrade::getDrawingGrade, bo.getDrawingGrade());
|
||||||
|
lqw.eq(bo.getYieldStress() != null, TdbSteelgrade::getYieldStress, bo.getYieldStress());
|
||||||
|
lqw.eq(bo.getYieldClass() != null, TdbSteelgrade::getYieldClass, bo.getYieldClass());
|
||||||
|
lqw.like(StringUtils.isNotBlank(bo.getContent()), TdbSteelgrade::getContent, bo.getContent());
|
||||||
|
lqw.orderByAsc(TdbSteelgrade::getSteelGrade);
|
||||||
|
return lqw;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Boolean insertByBo(TdbSteelgradeBo bo) {
|
||||||
|
TdbSteelgrade add = BeanUtil.toBean(bo, TdbSteelgrade.class);
|
||||||
|
boolean flag = baseMapper.insert(add) > 0;
|
||||||
|
if (flag) {
|
||||||
|
bo.setSteelGrade(add.getSteelGrade());
|
||||||
|
}
|
||||||
|
return flag;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Boolean updateByBo(TdbSteelgradeBo bo) {
|
||||||
|
TdbSteelgrade update = BeanUtil.toBean(bo, TdbSteelgrade.class);
|
||||||
|
return baseMapper.updateById(update) > 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Boolean deleteWithValidByIds(Collection<String> ids, Boolean isValid) {
|
||||||
|
if (isValid) {
|
||||||
|
// TODO 做一些业务上的校验,判断是否需要校验
|
||||||
|
}
|
||||||
|
return baseMapper.deleteBatchIds(ids) > 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,22 @@
|
|||||||
|
<?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.klp.pltcm.mapper.TdbSteelgradeMapper">
|
||||||
|
|
||||||
|
<resultMap type="com.klp.pltcm.domain.TdbSteelgrade" id="TdbSteelgradeResult">
|
||||||
|
<result property="steelGrade" column="steel_grade"/>
|
||||||
|
<result property="drawingGrade" column="drawing_grade"/>
|
||||||
|
<result property="yieldStress" column="yield_stress"/>
|
||||||
|
<result property="yieldClass" column="yield_class"/>
|
||||||
|
<result property="insDate" column="ins_date"/>
|
||||||
|
<result property="content" column="content"/>
|
||||||
|
<result property="weldCode" column="weld_code"/>
|
||||||
|
<result property="createBy" column="create_by"/>
|
||||||
|
<result property="createTime" column="create_time"/>
|
||||||
|
<result property="updateBy" column="update_by"/>
|
||||||
|
<result property="updateTime" column="update_time"/>
|
||||||
|
<result property="delFlag" column="del_flag"/>
|
||||||
|
</resultMap>
|
||||||
|
|
||||||
|
</mapper>
|
||||||
Reference in New Issue
Block a user