You've already forked FrameTour-BE
feat(printer): add print task review and reprint functionality
- Add reprint endpoint with printer name update - Implement pending review task query and management - Add task URL update for pending review tasks - Support bulk approve/reject of pending tasks - Extend task status enum with review-related states - Create ReprintRequest DTO for printer information - Update mapper to handle status transitions and queries - Modify service layer to support review workflow - Adjust XML mapper for new database operations
This commit is contained in:
@@ -6,6 +6,7 @@ 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.model.pc.printer.req.ReprintRequest;
|
||||
import com.ycwl.basic.service.printer.PrinterService;
|
||||
import com.ycwl.basic.utils.ApiResponse;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@@ -67,10 +68,55 @@ public class PrinterController {
|
||||
return ApiResponse.success(pageInfo);
|
||||
}
|
||||
|
||||
// 重新打印(将状态设置为0-未开始)
|
||||
// 重新打印(将状态设置为0-未开始,并更新打印机名称)
|
||||
@PostMapping("/task/reprint/{id}")
|
||||
public ApiResponse<Integer> reprint(@PathVariable("id") Integer id) {
|
||||
int result = printTaskMapper.updateStatus(id, 0);
|
||||
public ApiResponse<Integer> reprint(@PathVariable("id") Integer id, @RequestBody ReprintRequest request) {
|
||||
int result = printTaskMapper.updateStatusAndPrinter(id, 0, request.getPrinterName());
|
||||
return ApiResponse.success(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询待审核的打印任务
|
||||
* @param printerId 打印机ID(可选)
|
||||
* @return 待审核任务列表
|
||||
*/
|
||||
@GetMapping("/task/pending-review")
|
||||
public ApiResponse<List<PrintTaskEntity>> getPendingReviewTasks(Integer printerId) {
|
||||
List<PrintTaskEntity> tasks = printerService.getPendingReviewTasks(printerId);
|
||||
return ApiResponse.success(tasks);
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新待审核任务的URL(重新处理水印等)
|
||||
* @param taskId 任务ID
|
||||
* @param url 新的打印URL
|
||||
* @return 操作结果
|
||||
*/
|
||||
@PostMapping("/task/{taskId}/url")
|
||||
public ApiResponse<Boolean> updateTaskUrl(@PathVariable("taskId") Integer taskId, @RequestBody String url) {
|
||||
boolean success = printerService.updatePendingReviewTaskUrl(taskId, url);
|
||||
return ApiResponse.success(success);
|
||||
}
|
||||
|
||||
/**
|
||||
* 批准待审核任务,下发到打印队列
|
||||
* @param taskIds 任务ID列表
|
||||
* @return 成功数量
|
||||
*/
|
||||
@PostMapping("/task/approve")
|
||||
public ApiResponse<Integer> approveTasks(@RequestBody List<Integer> taskIds) {
|
||||
int count = printerService.approvePrintTasks(taskIds);
|
||||
return ApiResponse.success(count);
|
||||
}
|
||||
|
||||
/**
|
||||
* 拒绝待审核任务
|
||||
* @param taskIds 任务ID列表
|
||||
* @return 成功数量
|
||||
*/
|
||||
@PostMapping("/task/reject")
|
||||
public ApiResponse<Integer> rejectTasks(@RequestBody List<Integer> taskIds) {
|
||||
int count = printerService.rejectPrintTasks(taskIds);
|
||||
return ApiResponse.success(count);
|
||||
}
|
||||
}
|
||||
@@ -14,4 +14,36 @@ public interface PrintTaskMapper extends BaseMapper<PrintTaskEntity> {
|
||||
List<PrintTaskEntity> queryByCondition(@Param("printerId") Integer printerId, @Param("status") Integer status);
|
||||
|
||||
int updateStatus(@Param("id") Integer id, @Param("status") Integer status);
|
||||
|
||||
/**
|
||||
* 更新任务状态和打印机名称
|
||||
* @param id 任务ID
|
||||
* @param status 新状态
|
||||
* @param printerName 打印机名称
|
||||
* @return 更新行数
|
||||
*/
|
||||
int updateStatusAndPrinter(@Param("id") Integer id, @Param("status") Integer status, @Param("printerName") String printerName);
|
||||
|
||||
/**
|
||||
* 查询待审核的打印任务
|
||||
* @param printerId 打印机ID(可选)
|
||||
* @return 待审核任务列表
|
||||
*/
|
||||
List<PrintTaskEntity> queryPendingReviewTasks(@Param("printerId") Integer printerId);
|
||||
|
||||
/**
|
||||
* 更新任务URL
|
||||
* @param id 任务ID
|
||||
* @param url 新的打印URL
|
||||
* @return 更新行数
|
||||
*/
|
||||
int updateTaskUrl(@Param("id") Integer id, @Param("url") String url);
|
||||
|
||||
/**
|
||||
* 批量更新任务状态
|
||||
* @param ids 任务ID列表
|
||||
* @param status 新状态
|
||||
* @return 更新行数
|
||||
*/
|
||||
int batchUpdateStatus(@Param("ids") List<Integer> ids, @Param("status") Integer status);
|
||||
}
|
||||
|
||||
@@ -13,7 +13,7 @@ public class PrintTaskReqQuery extends BaseQueryParameterReq {
|
||||
private Integer printerId;
|
||||
|
||||
/**
|
||||
* 状态:0未开始,1已完成,2正在处理,3已失败
|
||||
* 状态:0待处理,1已完成,2已失败,3处理中,4待审核,5已取消
|
||||
*/
|
||||
private Integer status;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
package com.ycwl.basic.model.pc.printer.req;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 重新打印请求
|
||||
*/
|
||||
@Data
|
||||
public class ReprintRequest {
|
||||
/**
|
||||
* 打印机名称
|
||||
*/
|
||||
private String printerName;
|
||||
}
|
||||
@@ -2,6 +2,7 @@ package com.ycwl.basic.service.printer;
|
||||
|
||||
import com.ycwl.basic.model.mobile.face.FaceRecognizeResp;
|
||||
import com.ycwl.basic.model.mobile.order.PriceObj;
|
||||
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.resp.MemberPrintResp;
|
||||
import com.ycwl.basic.model.pc.printer.resp.PrinterResp;
|
||||
@@ -18,13 +19,13 @@ public interface PrinterService {
|
||||
List<PrinterResp> listByScenicId(Long scenicId);
|
||||
|
||||
ApiResponse<List<PrinterEntity>> list(PrinterEntity condition);
|
||||
|
||||
|
||||
ApiResponse<PrinterEntity> get(Integer id);
|
||||
|
||||
|
||||
ApiResponse<Integer> add(PrinterEntity entity);
|
||||
|
||||
|
||||
ApiResponse<Integer> update(PrinterEntity entity);
|
||||
|
||||
|
||||
ApiResponse<Integer> delete(Integer id);
|
||||
|
||||
List<PrintTaskResp> sync(PrinterSyncReq req);
|
||||
@@ -60,4 +61,33 @@ public interface PrinterService {
|
||||
FaceRecognizeResp useSample(Long userId, Long sampleId);
|
||||
|
||||
void autoAddPhotosToPreferPrint(Long faceId);
|
||||
|
||||
/**
|
||||
* 查询待审核的打印任务
|
||||
* @param printerId 打印机ID(可选)
|
||||
* @return 待审核任务列表
|
||||
*/
|
||||
List<PrintTaskEntity> getPendingReviewTasks(Integer printerId);
|
||||
|
||||
/**
|
||||
* 更新待审核任务的URL
|
||||
* @param taskId 任务ID
|
||||
* @param url 新的打印URL
|
||||
* @return 是否成功
|
||||
*/
|
||||
boolean updatePendingReviewTaskUrl(Integer taskId, String url);
|
||||
|
||||
/**
|
||||
* 批准待审核任务,下发到打印队列
|
||||
* @param taskIds 任务ID列表
|
||||
* @return 成功数量
|
||||
*/
|
||||
int approvePrintTasks(List<Integer> taskIds);
|
||||
|
||||
/**
|
||||
* 拒绝待审核任务
|
||||
* @param taskIds 任务ID列表
|
||||
* @return 成功数量
|
||||
*/
|
||||
int rejectPrintTasks(List<Integer> taskIds);
|
||||
}
|
||||
@@ -598,6 +598,7 @@ public class PrinterServiceImpl implements PrinterService {
|
||||
private static final int PRINTER_INDEX_EXPIRE_MINUTES = 5;
|
||||
private static final int TASK_STATUS_PENDING = 0;
|
||||
private static final int TASK_STATUS_PROCESSING = 3;
|
||||
private static final int TASK_STATUS_PENDING_REVIEW = 4; // 待审核
|
||||
private final Lock syncTaskLock = new ReentrantLock();
|
||||
|
||||
@Override
|
||||
@@ -736,12 +737,20 @@ public class PrinterServiceImpl implements PrinterService {
|
||||
for (int i = 0; i < quantity; i++) {
|
||||
// 获取打印机名称(支持轮询)
|
||||
String selectedPrinter = getNextPrinter(printer);
|
||||
|
||||
// 根据景区配置决定任务初始状态
|
||||
ScenicConfigManager scenicConfig = scenicRepository.getScenicConfigManager(order.getScenicId());
|
||||
Boolean purchaseNeedReview = scenicConfig.getBoolean("printer_manual_approve");
|
||||
int initialStatus = (purchaseNeedReview != null && purchaseNeedReview)
|
||||
? TASK_STATUS_PENDING_REVIEW
|
||||
: TASK_STATUS_PENDING;
|
||||
|
||||
PrintTaskEntity task = new PrintTaskEntity();
|
||||
task.setPrinterId(printer.getId());
|
||||
task.setPrinterName(selectedPrinter);
|
||||
task.setMpId(item.getId());
|
||||
task.setPaper(printer.getPreferPaper());
|
||||
task.setStatus(0);
|
||||
task.setStatus(initialStatus);
|
||||
task.setUrl(printUrl);
|
||||
task.setHeight(printer.getPreferH());
|
||||
task.setWidth(printer.getPreferW());
|
||||
@@ -752,6 +761,59 @@ public class PrinterServiceImpl implements PrinterService {
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询待审核的打印任务
|
||||
* @param printerId 打印机ID(可选)
|
||||
* @return 待审核任务列表
|
||||
*/
|
||||
@Override
|
||||
public List<PrintTaskEntity> getPendingReviewTasks(Integer printerId) {
|
||||
return printTaskMapper.queryPendingReviewTasks(printerId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新待审核任务的URL(可用于重新添加水印等操作)
|
||||
* @param taskId 任务ID
|
||||
* @param url 新的打印URL
|
||||
* @return 是否成功
|
||||
*/
|
||||
@Override
|
||||
public boolean updatePendingReviewTaskUrl(Integer taskId, String url) {
|
||||
if (taskId == null || url == null || url.trim().isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
int rows = printTaskMapper.updateTaskUrl(taskId, url);
|
||||
return rows > 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* 批准待审核任务,下发到打印队列
|
||||
* @param taskIds 任务ID列表
|
||||
* @return 成功数量
|
||||
*/
|
||||
@Override
|
||||
public int approvePrintTasks(List<Integer> taskIds) {
|
||||
if (taskIds == null || taskIds.isEmpty()) {
|
||||
return 0;
|
||||
}
|
||||
// 将状态从4(待审核)改为0(待处理)
|
||||
return printTaskMapper.batchUpdateStatus(taskIds, TASK_STATUS_PENDING);
|
||||
}
|
||||
|
||||
/**
|
||||
* 拒绝待审核任务(取消打印)
|
||||
* @param taskIds 任务ID列表
|
||||
* @return 成功数量
|
||||
*/
|
||||
@Override
|
||||
public int rejectPrintTasks(List<Integer> taskIds) {
|
||||
if (taskIds == null || taskIds.isEmpty()) {
|
||||
return 0;
|
||||
}
|
||||
// 将状态从4(待审核)改为5(已取消)
|
||||
return printTaskMapper.batchUpdateStatus(taskIds, 5);
|
||||
}
|
||||
|
||||
@Override
|
||||
public FaceRecognizeResp useSample(Long userId, Long sampleId) {
|
||||
// 1. 查询 faceSample 获取其 URL
|
||||
|
||||
@@ -24,4 +24,41 @@
|
||||
set status = #{status}, update_time = NOW()
|
||||
where id = #{id}
|
||||
</update>
|
||||
|
||||
<update id="updateStatusAndPrinter">
|
||||
update print_task
|
||||
<set>
|
||||
status = #{status},
|
||||
<if test="printerName != null and printerName != ''">
|
||||
printer_name = #{printerName},
|
||||
</if>
|
||||
update_time = NOW()
|
||||
</set>
|
||||
where id = #{id}
|
||||
</update>
|
||||
|
||||
<select id="queryPendingReviewTasks" resultType="com.ycwl.basic.model.pc.printer.entity.PrintTaskEntity">
|
||||
select id, printer_id, status, printer_name, url, width, height, mp_id, paper, create_time, update_time
|
||||
from print_task
|
||||
where status = 4
|
||||
<if test="printerId != null">
|
||||
and printer_id = #{printerId}
|
||||
</if>
|
||||
order by create_time desc
|
||||
</select>
|
||||
|
||||
<update id="updateTaskUrl">
|
||||
update print_task
|
||||
set url = #{url}, update_time = NOW()
|
||||
where id = #{id} and status = 4
|
||||
</update>
|
||||
|
||||
<update id="batchUpdateStatus">
|
||||
update print_task
|
||||
set status = #{status}, update_time = NOW()
|
||||
where id in
|
||||
<foreach collection="ids" item="id" open="(" separator="," close=")">
|
||||
#{id}
|
||||
</foreach>
|
||||
</update>
|
||||
</mapper>
|
||||
Reference in New Issue
Block a user