package com.zy.asrs.entity.param;
|
|
import com.zy.asrs.entity.LocMast;
|
import lombok.Data;
|
|
import java.util.ArrayList;
|
import java.util.Collections;
|
import java.util.List;
|
|
/**
|
* 空板出库阻塞检查结果
|
*/
|
@Data
|
public class LockingCheckResultParam {
|
|
/** 是否通过校验 */
|
private boolean success;
|
|
/** 出库方向: "ASC"(正序)或 "DESC"(倒序) */
|
private String direction;
|
|
/** 按出库方向排序后的选中库位列表 */
|
private List<LocMast> sortedSelected;
|
|
/** 失败时的错误信息 */
|
private String message;
|
|
/**
|
* 成功时的构造方法
|
*/
|
public LockingCheckResultParam(boolean success, String direction, List<LocMast> sortedSelected) {
|
this.success = success;
|
this.direction = direction;
|
// 防御性拷贝,防止外部修改
|
this.sortedSelected = sortedSelected != null
|
? new ArrayList<>(sortedSelected)
|
: Collections.emptyList();
|
}
|
|
/**
|
* 失败时的构造方法
|
*/
|
public LockingCheckResultParam(String message) {
|
this.success = false;
|
this.direction = null;
|
this.sortedSelected = Collections.emptyList();
|
this.message = message;
|
}
|
|
/**
|
* 快速创建成功结果(默认 ASC 方向)
|
*/
|
public static LockingCheckResultParam success(List<LocMast> sortedSelected) {
|
return new LockingCheckResultParam(true, "DEC", sortedSelected);
|
}
|
|
/**
|
* 快速创建成功结果(指定方向)
|
*/
|
public static LockingCheckResultParam success(String direction, List<LocMast> sortedSelected) {
|
return new LockingCheckResultParam(true, direction, sortedSelected);
|
}
|
|
/**
|
* 快速创建失败结果
|
*/
|
public static LockingCheckResultParam fail(String message) {
|
return new LockingCheckResultParam(message);
|
}
|
|
/**
|
* 判断是否成功(方便链式调用)
|
*/
|
public boolean isSuccess() {
|
return success;
|
}
|
|
/**
|
* 获取错误信息,如果成功则返回 null
|
*/
|
public String getErrorMessage() {
|
return success ? null : message;
|
}
|
}
|