feat(selfop): hide known zero inventory before turnover pagination
This commit is contained in:
+3
-2
@@ -10,12 +10,13 @@ public record InventoryTurnoverRequest(String sourceAccount, String warehouseCod
|
||||
@DateTimeFormat(iso=DateTimeFormat.ISO.DATE) LocalDate endDate, Integer baseWindowDays,
|
||||
String groupBy, String customerCode, String sku, String focus, Integer coverageDaysThreshold,
|
||||
String turnoverStatus, String sortBy, Integer current, Integer size, Boolean includeOverview,
|
||||
String snapshotContext) {
|
||||
String snapshotContext, Boolean hideZeroInventory) {
|
||||
private static final Set<String> PARAMETERS=Set.of("sourceAccount","warehouseCode","endDate","baseWindowDays",
|
||||
"groupBy","customerCode","sku","focus","coverageDaysThreshold","turnoverStatus","sortBy","current","size","includeOverview","snapshotContext");
|
||||
"groupBy","customerCode","sku","focus","coverageDaysThreshold","turnoverStatus","sortBy","current","size","includeOverview","snapshotContext","hideZeroInventory");
|
||||
public static void validateParameters(Set<String> keys) {
|
||||
if(!PARAMETERS.containsAll(keys)) throw new BizException("库存周转不接受其他视图的查询参数");
|
||||
}
|
||||
public boolean hideZero(){return !Boolean.FALSE.equals(hideZeroInventory);}
|
||||
public int days(){return baseWindowDays==null?30:baseWindowDays;}
|
||||
public java.util.List<Integer> windows(){return java.util.stream.Stream.of(7,15,30,days()).distinct().sorted().toList();}
|
||||
public String group(){return groupBy==null?"SKU":groupBy;}
|
||||
|
||||
+1
@@ -209,6 +209,7 @@ public final class InventoryTurnoverSql {
|
||||
case "UNASSESSABLE" -> "unassessable>0";
|
||||
default -> "1=1";
|
||||
};
|
||||
if(p.query.hideZero()) predicate+=" AND (physical IS NULL OR physical<>0)";
|
||||
if(p.query.turnoverStatus()!=null) predicate+=" AND sample_count<#{p.query.days}";
|
||||
if(!owner&&p.query.sku()!=null) predicate+=" AND sku_code=#{p.query.sku}";
|
||||
return " WHERE "+predicate;
|
||||
|
||||
Reference in New Issue
Block a user