You've already forked FrameTour-BE
feat(printer): 添加打印任务分页查询和重新打印功能- 引入 PageHelper 和 PageInfo 实现分页查询
All checks were successful
ZhenTu-BE/pipeline/head This commit looks good
All checks were successful
ZhenTu-BE/pipeline/head This commit looks good
- 新增 PrintTaskMapper 接口方法 queryByCondition 和 updateStatus
- 扩展 PrintTaskEntity 实体类,新增 mpId 和 paper 字段- 在 PrinterController 中新增 /task/page 和 /task/reprint/{id} 接口- 更新 PrintTaskMapper.xml,添加查询和更新状态的 SQL语句- 优化打印任务插入逻辑,补充 mpId 和 paper 字段赋值
This commit is contained in:
@@ -1,6 +1,11 @@
|
||||
package com.ycwl.basic.controller.pc;
|
||||
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import com.ycwl.basic.mapper.PrintTaskMapper;
|
||||
import com.ycwl.basic.model.pc.printer.entity.PrintTaskEntity;
|
||||
import com.ycwl.basic.model.pc.printer.entity.PrinterEntity;
|
||||
import com.ycwl.basic.model.pc.printer.req.PrintTaskReqQuery;
|
||||
import com.ycwl.basic.service.printer.PrinterService;
|
||||
import com.ycwl.basic.utils.ApiResponse;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@@ -20,6 +25,9 @@ public class PrinterController {
|
||||
@Autowired
|
||||
private PrinterService printerService;
|
||||
|
||||
@Autowired
|
||||
private PrintTaskMapper printTaskMapper;
|
||||
|
||||
// 查询列表
|
||||
@PostMapping("/list")
|
||||
public ApiResponse<List<PrinterEntity>> list(@RequestBody PrinterEntity condition) {
|
||||
@@ -49,4 +57,20 @@ public class PrinterController {
|
||||
public ApiResponse<Integer> delete(@PathVariable("id") Integer id) {
|
||||
return printerService.delete(id);
|
||||
}
|
||||
|
||||
// 分页查询打印任务
|
||||
@PostMapping("/task/page")
|
||||
public ApiResponse<PageInfo<PrintTaskEntity>> taskPage(@RequestBody PrintTaskReqQuery req) {
|
||||
PageHelper.startPage(req.getPageNum(), req.getPageSize());
|
||||
List<PrintTaskEntity> list = printTaskMapper.queryByCondition(req.getPrinterId(), req.getStatus());
|
||||
PageInfo<PrintTaskEntity> pageInfo = new PageInfo<>(list);
|
||||
return ApiResponse.success(pageInfo);
|
||||
}
|
||||
|
||||
// 重新打印(将状态设置为0-未开始)
|
||||
@PostMapping("/task/reprint/{id}")
|
||||
public ApiResponse<Integer> reprint(@PathVariable("id") Integer id) {
|
||||
int result = printTaskMapper.updateStatus(id, 0);
|
||||
return ApiResponse.success(result);
|
||||
}
|
||||
}
|
||||
@@ -3,8 +3,15 @@ package com.ycwl.basic.mapper;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.ycwl.basic.model.pc.printer.entity.PrintTaskEntity;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Mapper
|
||||
public interface PrintTaskMapper extends BaseMapper<PrintTaskEntity> {
|
||||
int insertTask(PrintTaskEntity entity);
|
||||
|
||||
List<PrintTaskEntity> queryByCondition(@Param("printerId") Integer printerId, @Param("status") Integer status);
|
||||
|
||||
int updateStatus(@Param("id") Integer id, @Param("status") Integer status);
|
||||
}
|
||||
|
||||
@@ -28,6 +28,8 @@ public class PrintTaskEntity {
|
||||
|
||||
@TableField("height")
|
||||
private Integer height;
|
||||
private Integer mpId;
|
||||
private String paper;
|
||||
|
||||
@TableField("create_time")
|
||||
private Date createTime;
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
package com.ycwl.basic.model.pc.printer.req;
|
||||
|
||||
import com.ycwl.basic.model.common.BaseQueryParameterReq;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Data
|
||||
public class PrintTaskReqQuery extends BaseQueryParameterReq {
|
||||
/**
|
||||
* 打印机ID
|
||||
*/
|
||||
private Integer printerId;
|
||||
|
||||
/**
|
||||
* 状态:0未开始,1已完成,2正在处理,3已失败
|
||||
*/
|
||||
private Integer status;
|
||||
}
|
||||
@@ -561,6 +561,8 @@ public class PrinterServiceImpl implements PrinterService {
|
||||
|
||||
PrintTaskEntity task = new PrintTaskEntity();
|
||||
task.setPrinterId(printer.getId());
|
||||
task.setMpId(item.getId());
|
||||
task.setPaper(printer.getPreferPaper());
|
||||
task.setStatus(0);
|
||||
task.setUrl(printUrl);
|
||||
task.setHeight(printer.getPreferH());
|
||||
|
||||
Reference in New Issue
Block a user