refactor(ops): 工单中心查询接口参数封装重构

优化 OrderCenterController.queryPage() 方法签名,从 9 个独立参数封装为单个对象,提升代码可维护性。

主要变更:
1. OrderQuery 改用 Lombok @Data 替代手写 getter/setter(减少 ~120 行)
2. OrderQuery.status 从 String 改为 List<String>,支持前端多状态筛选
3. OrderQueryServiceImpl 使用 inIfPresent() 生成 IN 查询(兼容单选和多选)
4. OrderCenterController 接收 OrderQuery 对象替代 9 个 @RequestParam
5. OrderCenterControllerTest 适配新签名,新增多状态测试用例

向后兼容:
- 前端传单个 status=PENDING,Spring 自动转 List.of("PENDING")
- 前端传多个 status=A&status=B,Spring 自动转 List.of("A","B")
- 原有单状态查询不受影响

影响模块:Ops Biz、Ops Server

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
lzh
2026-02-02 22:37:06 +08:00
parent e95080dc8a
commit bdf5b640b0
4 changed files with 83 additions and 172 deletions

View File

@@ -3,7 +3,11 @@ package com.viewsh.module.ops.service;
import com.viewsh.framework.common.pojo.PageParam;
import com.viewsh.framework.common.pojo.PageResult;
import com.viewsh.module.ops.dal.dataobject.workorder.OpsOrderDO;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.util.List;
import java.util.Map;
/**
@@ -51,145 +55,29 @@ public interface OrderQueryService {
/**
* 工单查询条件
*/
@Data
@EqualsAndHashCode(callSuper = true)
class OrderQuery extends PageParam {
/**
* 工单类型(可选)
*/
@Schema(description = "工单类型", example = "CLEAN")
private String orderType;
/**
* 工单状态(可选)
*/
private String status;
@Schema(description = "工单状态,支持多选", example = "PENDING,DISPATCHED")
private List<String> status;
/**
* 优先级(可选)
*/
@Schema(description = "优先级0=P0/1=P1/2=P2", example = "1")
private Integer priority;
/**
* 区域ID可选
*/
@Schema(description = "区域ID", example = "100")
private Long areaId;
/**
* 执行人ID可选
*/
@Schema(description = "执行人ID", example = "30001")
private Long assigneeId;
/**
* 工单编号模糊查询(可选)
*/
@Schema(description = "工单编号(模糊查询)", example = "WO2025")
private String orderCode;
/**
* 标题模糊查询(可选)
*/
@Schema(description = "标题(模糊查询)", example = "A栋")
private String title;
public String getOrderType() {
return orderType;
}
public void setOrderType(String orderType) {
this.orderType = orderType;
}
public String getStatus() {
return status;
}
public void setStatus(String status) {
this.status = status;
}
public Integer getPriority() {
return priority;
}
public void setPriority(Integer priority) {
this.priority = priority;
}
public Long getAreaId() {
return areaId;
}
public void setAreaId(Long areaId) {
this.areaId = areaId;
}
public Long getAssigneeId() {
return assigneeId;
}
public void setAssigneeId(Long assigneeId) {
this.assigneeId = assigneeId;
}
public String getOrderCode() {
return orderCode;
}
public void setOrderCode(String orderCode) {
this.orderCode = orderCode;
}
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
public static OrderQuery builder() {
return new OrderQuery();
}
public OrderQuery withPageNo(Integer pageNo) {
this.setPageNo(pageNo);
return this;
}
public OrderQuery withPageSize(Integer pageSize) {
this.setPageSize(pageSize);
return this;
}
public OrderQuery withOrderType(String orderType) {
this.orderType = orderType;
return this;
}
public OrderQuery withStatus(String status) {
this.status = status;
return this;
}
public OrderQuery withPriority(Integer priority) {
this.priority = priority;
return this;
}
public OrderQuery withAreaId(Long areaId) {
this.areaId = areaId;
return this;
}
public OrderQuery withAssigneeId(Long assigneeId) {
this.assigneeId = assigneeId;
return this;
}
public OrderQuery withOrderCode(String orderCode) {
this.orderCode = orderCode;
return this;
}
public OrderQuery withTitle(String title) {
this.title = title;
return this;
}
}
}

View File

@@ -39,7 +39,7 @@ public class OrderQueryServiceImpl implements OrderQueryService {
// 1. 构建查询条件
LambdaQueryWrapperX<OpsOrderDO> wrapper = new LambdaQueryWrapperX<OpsOrderDO>()
.eqIfPresent(OpsOrderDO::getOrderType, query.getOrderType())
.eqIfPresent(OpsOrderDO::getStatus, query.getStatus())
.inIfPresent(OpsOrderDO::getStatus, query.getStatus())
.eqIfPresent(OpsOrderDO::getPriority, query.getPriority())
.eqIfPresent(OpsOrderDO::getAreaId, query.getAreaId())
.eqIfPresent(OpsOrderDO::getAssigneeId, query.getAssigneeId())
@@ -126,7 +126,9 @@ public class OrderQueryServiceImpl implements OrderQueryService {
.status(order.getStatus())
.areaId(order.getAreaId())
.location(order.getLocation())
.sourceType(order.getSourceType())
.assigneeId(order.getAssigneeId())
.assigneeName(order.getAssigneeName())
.startTime(order.getStartTime())
.endTime(order.getEndTime())
.createTime(order.getCreateTime())