增加批次管理功能
This commit is contained in:
parent
c15152b856
commit
e211b11349
@ -0,0 +1,106 @@
|
|||||||
|
package net.ferrum.web.controller.business;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Arrays;
|
||||||
|
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
import javax.validation.constraints.*;
|
||||||
|
import cn.dev33.satoken.annotation.SaCheckPermission;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
import org.springframework.validation.annotation.Validated;
|
||||||
|
import net.ferrum.common.annotation.RepeatSubmit;
|
||||||
|
import net.ferrum.common.annotation.Log;
|
||||||
|
import net.ferrum.common.core.controller.BaseController;
|
||||||
|
import net.ferrum.common.core.domain.PageQuery;
|
||||||
|
import net.ferrum.common.core.domain.R;
|
||||||
|
import net.ferrum.common.core.validate.AddGroup;
|
||||||
|
import net.ferrum.common.core.validate.EditGroup;
|
||||||
|
import net.ferrum.common.enums.BusinessType;
|
||||||
|
import net.ferrum.common.utils.poi.ExcelUtil;
|
||||||
|
import net.ferrum.business.domain.vo.QsBatchVo;
|
||||||
|
import net.ferrum.business.domain.bo.QsBatchBo;
|
||||||
|
import net.ferrum.business.service.IQsBatchService;
|
||||||
|
import net.ferrum.common.core.page.TableDataInfo;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 批次管理
|
||||||
|
*
|
||||||
|
* @author tiezx
|
||||||
|
* @date 2025-07-18
|
||||||
|
*/
|
||||||
|
@Validated
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/business/batch")
|
||||||
|
public class QsBatchController extends BaseController {
|
||||||
|
|
||||||
|
private final IQsBatchService iQsBatchService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询批次管理列表
|
||||||
|
*/
|
||||||
|
@SaCheckPermission("business:batch:list")
|
||||||
|
@GetMapping("/list")
|
||||||
|
public TableDataInfo<QsBatchVo> list(QsBatchBo bo, PageQuery pageQuery) {
|
||||||
|
return iQsBatchService.queryPageList(bo, pageQuery);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 导出批次管理列表
|
||||||
|
*/
|
||||||
|
@SaCheckPermission("business:batch:export")
|
||||||
|
@Log(title = "批次管理", businessType = BusinessType.EXPORT)
|
||||||
|
@PostMapping("/export")
|
||||||
|
public void export(QsBatchBo bo, HttpServletResponse response) {
|
||||||
|
List<QsBatchVo> list = iQsBatchService.queryList(bo);
|
||||||
|
ExcelUtil.exportExcel(list, "批次管理", QsBatchVo.class, response);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取批次管理详细信息
|
||||||
|
*
|
||||||
|
* @param batchId 主键
|
||||||
|
*/
|
||||||
|
@SaCheckPermission("business:batch:query")
|
||||||
|
@GetMapping("/{batchId}")
|
||||||
|
public R<QsBatchVo> getInfo(@NotNull(message = "主键不能为空")
|
||||||
|
@PathVariable Long batchId) {
|
||||||
|
return R.ok(iQsBatchService.queryById(batchId));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 新增批次管理
|
||||||
|
*/
|
||||||
|
@SaCheckPermission("business:batch:add")
|
||||||
|
@Log(title = "批次管理", businessType = BusinessType.INSERT)
|
||||||
|
@RepeatSubmit()
|
||||||
|
@PostMapping()
|
||||||
|
public R<Void> add(@Validated(AddGroup.class) @RequestBody QsBatchBo bo) {
|
||||||
|
return toAjax(iQsBatchService.insertByBo(bo));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改批次管理
|
||||||
|
*/
|
||||||
|
@SaCheckPermission("business:batch:edit")
|
||||||
|
@Log(title = "批次管理", businessType = BusinessType.UPDATE)
|
||||||
|
@RepeatSubmit()
|
||||||
|
@PutMapping()
|
||||||
|
public R<Void> edit(@Validated(EditGroup.class) @RequestBody QsBatchBo bo) {
|
||||||
|
return toAjax(iQsBatchService.updateByBo(bo));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除批次管理
|
||||||
|
*
|
||||||
|
* @param batchIds 主键串
|
||||||
|
*/
|
||||||
|
@SaCheckPermission("business:batch:remove")
|
||||||
|
@Log(title = "批次管理", businessType = BusinessType.DELETE)
|
||||||
|
@DeleteMapping("/{batchIds}")
|
||||||
|
public R<Void> remove(@NotEmpty(message = "主键不能为空")
|
||||||
|
@PathVariable Long[] batchIds) {
|
||||||
|
return toAjax(iQsBatchService.deleteWithValidByIds(Arrays.asList(batchIds), true));
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,59 @@
|
|||||||
|
package net.ferrum.business.domain;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.*;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
import net.ferrum.common.core.domain.BaseEntity;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 批次管理对象 qs_batch
|
||||||
|
*
|
||||||
|
* @author tiezx
|
||||||
|
* @date 2025-07-18
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@EqualsAndHashCode(callSuper = true)
|
||||||
|
@TableName("qs_batch")
|
||||||
|
public class QsBatch extends BaseEntity {
|
||||||
|
|
||||||
|
private static final long serialVersionUID=1L;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 批次ID
|
||||||
|
*/
|
||||||
|
@TableId(value = "batch_id")
|
||||||
|
private Long batchId;
|
||||||
|
/**
|
||||||
|
* 批次编号
|
||||||
|
*/
|
||||||
|
private String batchNo;
|
||||||
|
/**
|
||||||
|
* 批次名称
|
||||||
|
*/
|
||||||
|
private String batchName;
|
||||||
|
/**
|
||||||
|
* 开始时间
|
||||||
|
*/
|
||||||
|
private Date batchStartDate;
|
||||||
|
/**
|
||||||
|
* 计划结束时间
|
||||||
|
*/
|
||||||
|
private Date batchPlanEndDate;
|
||||||
|
/**
|
||||||
|
* 结束日期
|
||||||
|
*/
|
||||||
|
private Date batchEndDate;
|
||||||
|
/**
|
||||||
|
* 删除标志(0代表存在 2代表删除)
|
||||||
|
*/
|
||||||
|
@TableLogic
|
||||||
|
private String delFlag;
|
||||||
|
/**
|
||||||
|
* 备注
|
||||||
|
*/
|
||||||
|
private String remark;
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,66 @@
|
|||||||
|
package net.ferrum.business.domain.bo;
|
||||||
|
|
||||||
|
import net.ferrum.common.core.validate.AddGroup;
|
||||||
|
import net.ferrum.common.core.validate.EditGroup;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
import javax.validation.constraints.*;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
import net.ferrum.common.core.domain.BaseEntity;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 批次管理业务对象 qs_batch
|
||||||
|
*
|
||||||
|
* @author tiezx
|
||||||
|
* @date 2025-07-18
|
||||||
|
*/
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@EqualsAndHashCode(callSuper = true)
|
||||||
|
public class QsBatchBo extends BaseEntity {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 批次ID
|
||||||
|
*/
|
||||||
|
@NotNull(message = "批次ID不能为空", groups = { EditGroup.class })
|
||||||
|
private Long batchId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 批次编号
|
||||||
|
*/
|
||||||
|
@NotBlank(message = "批次编号不能为空", groups = { AddGroup.class, EditGroup.class })
|
||||||
|
private String batchNo;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 批次名称
|
||||||
|
*/
|
||||||
|
@NotBlank(message = "批次名称不能为空", groups = { AddGroup.class, EditGroup.class })
|
||||||
|
private String batchName;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 开始时间
|
||||||
|
*/
|
||||||
|
@NotNull(message = "开始时间不能为空", groups = { AddGroup.class, EditGroup.class })
|
||||||
|
private Date batchStartDate;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 计划结束时间
|
||||||
|
*/
|
||||||
|
@NotNull(message = "计划结束时间不能为空", groups = { AddGroup.class, EditGroup.class })
|
||||||
|
private Date batchPlanEndDate;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 结束日期
|
||||||
|
*/
|
||||||
|
private Date batchEndDate;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 备注
|
||||||
|
*/
|
||||||
|
@NotBlank(message = "备注不能为空", groups = { AddGroup.class, EditGroup.class })
|
||||||
|
private String remark;
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,65 @@
|
|||||||
|
package net.ferrum.business.domain.vo;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
|
||||||
|
import com.alibaba.excel.annotation.ExcelProperty;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 批次管理视图对象 qs_batch
|
||||||
|
*
|
||||||
|
* @author tiezx
|
||||||
|
* @date 2025-07-18
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@ExcelIgnoreUnannotated
|
||||||
|
public class QsBatchVo {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 批次ID
|
||||||
|
*/
|
||||||
|
@ExcelProperty(value = "批次ID")
|
||||||
|
private Long batchId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 批次编号
|
||||||
|
*/
|
||||||
|
@ExcelProperty(value = "批次编号")
|
||||||
|
private String batchNo;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 批次名称
|
||||||
|
*/
|
||||||
|
@ExcelProperty(value = "批次名称")
|
||||||
|
private String batchName;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 开始时间
|
||||||
|
*/
|
||||||
|
@ExcelProperty(value = "开始时间")
|
||||||
|
private Date batchStartDate;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 计划结束时间
|
||||||
|
*/
|
||||||
|
@ExcelProperty(value = "计划结束时间")
|
||||||
|
private Date batchPlanEndDate;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 结束日期
|
||||||
|
*/
|
||||||
|
@ExcelProperty(value = "结束日期")
|
||||||
|
private Date batchEndDate;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 备注
|
||||||
|
*/
|
||||||
|
@ExcelProperty(value = "备注")
|
||||||
|
private String remark;
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,15 @@
|
|||||||
|
package net.ferrum.business.mapper;
|
||||||
|
|
||||||
|
import net.ferrum.business.domain.QsBatch;
|
||||||
|
import net.ferrum.business.domain.vo.QsBatchVo;
|
||||||
|
import net.ferrum.common.core.mapper.BaseMapperPlus;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 批次管理Mapper接口
|
||||||
|
*
|
||||||
|
* @author tiezx
|
||||||
|
* @date 2025-07-18
|
||||||
|
*/
|
||||||
|
public interface QsBatchMapper extends BaseMapperPlus<QsBatchMapper, QsBatch, QsBatchVo> {
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,48 @@
|
|||||||
|
package net.ferrum.business.service;
|
||||||
|
|
||||||
|
import net.ferrum.business.domain.vo.QsBatchVo;
|
||||||
|
import net.ferrum.business.domain.bo.QsBatchBo;
|
||||||
|
import net.ferrum.common.core.page.TableDataInfo;
|
||||||
|
import net.ferrum.common.core.domain.PageQuery;
|
||||||
|
|
||||||
|
import java.util.Collection;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 批次管理Service接口
|
||||||
|
*
|
||||||
|
* @author tiezx
|
||||||
|
* @date 2025-07-18
|
||||||
|
*/
|
||||||
|
public interface IQsBatchService {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询批次管理
|
||||||
|
*/
|
||||||
|
QsBatchVo queryById(Long batchId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询批次管理列表
|
||||||
|
*/
|
||||||
|
TableDataInfo<QsBatchVo> queryPageList(QsBatchBo bo, PageQuery pageQuery);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询批次管理列表
|
||||||
|
*/
|
||||||
|
List<QsBatchVo> queryList(QsBatchBo bo);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 新增批次管理
|
||||||
|
*/
|
||||||
|
Boolean insertByBo(QsBatchBo bo);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改批次管理
|
||||||
|
*/
|
||||||
|
Boolean updateByBo(QsBatchBo bo);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 校验并批量删除批次管理信息
|
||||||
|
*/
|
||||||
|
Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid);
|
||||||
|
}
|
||||||
@ -0,0 +1,116 @@
|
|||||||
|
package net.ferrum.business.service.impl;
|
||||||
|
|
||||||
|
import cn.hutool.core.bean.BeanUtil;
|
||||||
|
import net.ferrum.common.utils.StringUtils;
|
||||||
|
import net.ferrum.common.core.page.TableDataInfo;
|
||||||
|
import net.ferrum.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 lombok.RequiredArgsConstructor;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
import net.ferrum.business.domain.bo.QsBatchBo;
|
||||||
|
import net.ferrum.business.domain.vo.QsBatchVo;
|
||||||
|
import net.ferrum.business.domain.QsBatch;
|
||||||
|
import net.ferrum.business.mapper.QsBatchMapper;
|
||||||
|
import net.ferrum.business.service.IQsBatchService;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Collection;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 批次管理Service业务层处理
|
||||||
|
*
|
||||||
|
* @author tiezx
|
||||||
|
* @date 2025-07-18
|
||||||
|
*/
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
@Service
|
||||||
|
public class QsBatchServiceImpl implements IQsBatchService {
|
||||||
|
|
||||||
|
private final QsBatchMapper baseMapper;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询批次管理
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public QsBatchVo queryById(Long batchId){
|
||||||
|
return baseMapper.selectVoById(batchId);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询批次管理列表
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public TableDataInfo<QsBatchVo> queryPageList(QsBatchBo bo, PageQuery pageQuery) {
|
||||||
|
LambdaQueryWrapper<QsBatch> lqw = buildQueryWrapper(bo);
|
||||||
|
Page<QsBatchVo> result = baseMapper.selectVoPage(pageQuery.build(), lqw);
|
||||||
|
return TableDataInfo.build(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询批次管理列表
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public List<QsBatchVo> queryList(QsBatchBo bo) {
|
||||||
|
LambdaQueryWrapper<QsBatch> lqw = buildQueryWrapper(bo);
|
||||||
|
return baseMapper.selectVoList(lqw);
|
||||||
|
}
|
||||||
|
|
||||||
|
private LambdaQueryWrapper<QsBatch> buildQueryWrapper(QsBatchBo bo) {
|
||||||
|
Map<String, Object> params = bo.getParams();
|
||||||
|
LambdaQueryWrapper<QsBatch> lqw = Wrappers.lambdaQuery();
|
||||||
|
lqw.eq(StringUtils.isNotBlank(bo.getBatchNo()), QsBatch::getBatchNo, bo.getBatchNo());
|
||||||
|
lqw.like(StringUtils.isNotBlank(bo.getBatchName()), QsBatch::getBatchName, bo.getBatchName());
|
||||||
|
lqw.between(params.get("beginBatchStartDate") != null && params.get("endBatchStartDate") != null,
|
||||||
|
QsBatch::getBatchStartDate ,params.get("beginBatchStartDate"), params.get("endBatchStartDate"));
|
||||||
|
lqw.between(params.get("beginBatchPlanEndDate") != null && params.get("endBatchPlanEndDate") != null,
|
||||||
|
QsBatch::getBatchPlanEndDate ,params.get("beginBatchPlanEndDate"), params.get("endBatchPlanEndDate"));
|
||||||
|
lqw.between(params.get("beginBatchEndDate") != null && params.get("endBatchEndDate") != null,
|
||||||
|
QsBatch::getBatchEndDate ,params.get("beginBatchEndDate"), params.get("endBatchEndDate"));
|
||||||
|
return lqw;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 新增批次管理
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public Boolean insertByBo(QsBatchBo bo) {
|
||||||
|
QsBatch add = BeanUtil.toBean(bo, QsBatch.class);
|
||||||
|
validEntityBeforeSave(add);
|
||||||
|
boolean flag = baseMapper.insert(add) > 0;
|
||||||
|
if (flag) {
|
||||||
|
bo.setBatchId(add.getBatchId());
|
||||||
|
}
|
||||||
|
return flag;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改批次管理
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public Boolean updateByBo(QsBatchBo bo) {
|
||||||
|
QsBatch update = BeanUtil.toBean(bo, QsBatch.class);
|
||||||
|
validEntityBeforeSave(update);
|
||||||
|
return baseMapper.updateById(update) > 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 保存前的数据校验
|
||||||
|
*/
|
||||||
|
private void validEntityBeforeSave(QsBatch entity){
|
||||||
|
//TODO 做一些数据校验,如唯一约束
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 批量删除批次管理
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid) {
|
||||||
|
if(isValid){
|
||||||
|
//TODO 做一些业务上的校验,判断是否需要校验
|
||||||
|
}
|
||||||
|
return baseMapper.deleteBatchIds(ids) > 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,23 @@
|
|||||||
|
<?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="net.ferrum.business.mapper.QsBatchMapper">
|
||||||
|
|
||||||
|
<resultMap type="net.ferrum.business.domain.QsBatch" id="QsBatchResult">
|
||||||
|
<result property="batchId" column="batch_id"/>
|
||||||
|
<result property="batchNo" column="batch_no"/>
|
||||||
|
<result property="batchName" column="batch_name"/>
|
||||||
|
<result property="batchStartDate" column="batch_start_date"/>
|
||||||
|
<result property="batchPlanEndDate" column="batch_plan_end_date"/>
|
||||||
|
<result property="batchEndDate" column="batch_end_date"/>
|
||||||
|
<result property="delFlag" column="del_flag"/>
|
||||||
|
<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="remark" column="remark"/>
|
||||||
|
</resultMap>
|
||||||
|
|
||||||
|
|
||||||
|
</mapper>
|
||||||
Loading…
x
Reference in New Issue
Block a user