handy 1 bulan lalu
induk
melakukan
9b232cef80
1 mengubah file dengan 57 tambahan dan 2 penghapusan
  1. 57 2
      src/components/warehouse-layout-enhancers.ts

+ 57 - 2
src/components/warehouse-layout-enhancers.ts

@@ -17,6 +17,13 @@ interface LocalColumnAisleRule {
   rowRange?: [number, number]
 }
 
+interface LocalColumnShiftRule {
+  startColumn: number
+  shiftCols: number
+  rows?: number[]
+  rowRange?: [number, number]
+}
+
 interface GlobalColumnAisleRule {
   breakpoint: number
   excludeRows?: number[]
@@ -91,6 +98,54 @@ const firstFloorEnhancer: WarehouseLayoutEnhancer = {
         gapCols: 3
       }
     ]
+    const firstFloorLocalColumnShifts: LocalColumnShiftRule[] = [
+      {
+        rows: [6, 13],
+        startColumn: 0,
+        shiftCols: 1
+      },
+      {
+        rows: [6, 13],
+        startColumn: 5,
+        shiftCols: 1
+      },
+      {
+        rows: [6, 13],
+        startColumn: 11,
+        shiftCols: 1
+      },
+      {
+        rows: [6, 13],
+        startColumn: 17,
+        shiftCols: 1
+      },
+      {
+        rows: [7],
+        startColumn: 20,
+        shiftCols: 1
+      }
+    ]
+
+    const columnShiftCount = firstFloorLocalColumnShifts.reduce((total, rule) => {
+      const matchedRows = rule.rows?.includes(parsedLocation.y) ?? false
+      const matchedRange = rule.rowRange
+        ? parsedLocation.y >= rule.rowRange[0] && parsedLocation.y <= rule.rowRange[1]
+        : false
+
+      if ((matchedRows || matchedRange) && parsedLocation.x >= rule.startColumn) {
+        return total + rule.shiftCols
+      }
+
+      return total
+    }, 0)
+    const effectiveColumn = parsedLocation.x + columnShiftCount
+
+    if (columnShiftCount > 0) {
+      nextPosition = {
+        ...nextPosition,
+        gridCol: nextPosition.gridCol + columnShiftCount
+      }
+    }
 
     // 1 层增强规则:在指定列断点之间插入整列过道。
     firstFloorGlobalColumnAisles.forEach((rule) => {
@@ -99,7 +154,7 @@ const firstFloorEnhancer: WarehouseLayoutEnhancer = {
         ? parsedLocation.y >= rule.excludeRowRange[0] && parsedLocation.y <= rule.excludeRowRange[1]
         : false
 
-      if (!excludedByRows && !excludedByRange && parsedLocation.x >= rule.breakpoint) {
+      if (!excludedByRows && !excludedByRange && effectiveColumn >= rule.breakpoint) {
         nextPosition = {
           ...nextPosition,
           gridCol: nextPosition.gridCol + 1
@@ -124,7 +179,7 @@ const firstFloorEnhancer: WarehouseLayoutEnhancer = {
         ? parsedLocation.y >= rule.rowRange[0] && parsedLocation.y <= rule.rowRange[1]
         : false
 
-      if ((matchedRows || matchedRange) && parsedLocation.x > rule.afterColumn) {
+      if ((matchedRows || matchedRange) && effectiveColumn > rule.afterColumn) {
         nextPosition = {
           ...nextPosition,
           gridCol: nextPosition.gridCol + rule.gapCols