diff --git a/src/main/java/com/huaheng/api/wcs/service/overrideHandle/OverrideHandleServiceImpl.java b/src/main/java/com/huaheng/api/wcs/service/overrideHandle/OverrideHandleServiceImpl.java
index d37e77d..f29fb09 100644
--- a/src/main/java/com/huaheng/api/wcs/service/overrideHandle/OverrideHandleServiceImpl.java
+++ b/src/main/java/com/huaheng/api/wcs/service/overrideHandle/OverrideHandleServiceImpl.java
@@ -147,7 +147,7 @@ public class OverrideHandleServiceImpl implements OverrideHandleService {
             }
         }
 
-        String locationCode = locationAllocationService.allocation(high, area, roadWay, containerCode, frequencyLocation, onlyEmptyContainer, isSelfCreated, isFlammable, false, taskNo);
+        String locationCode = locationAllocationService.allocation(high, area, roadWay, containerCode, frequencyLocation, onlyEmptyContainer, isSelfCreated, isFlammable, taskNo);
         if (StringUtils.isEmpty(locationCode)) {
             return AjaxResult.error("没有库位可分配");
         }
diff --git a/src/main/java/com/huaheng/api/wcs/service/taskAssignService/TaskAssignServiceImpl.java b/src/main/java/com/huaheng/api/wcs/service/taskAssignService/TaskAssignServiceImpl.java
index aecf7f6..14fd72a 100644
--- a/src/main/java/com/huaheng/api/wcs/service/taskAssignService/TaskAssignServiceImpl.java
+++ b/src/main/java/com/huaheng/api/wcs/service/taskAssignService/TaskAssignServiceImpl.java
@@ -170,7 +170,7 @@ public class TaskAssignServiceImpl implements TaskAssignService {
                             }
                             //移库分配库位
                             String destinationLocationCode = locationAllocationService.allocation(insideLocation.getHigh(), insideLocation.getArea(), "5",
-                                    containerCode, insideLocation.getFrequencyLocation(), insideLocation.getOnlyEmptyContainer(), isSelfCreated, isFlammable, true, "");
+                                    containerCode, insideLocation.getFrequencyLocation(), insideLocation.getOnlyEmptyContainer(), isSelfCreated, isFlammable, "");
                             if (StringUtils.isEmpty(destinationLocationCode)) {
                                 return AjaxResult.error("移库没有剩余库位");
                             } else if (destinationLocationCode.length() > 10) {
diff --git a/src/main/java/com/huaheng/api/wcs/service/warecellAllocation/LocationAllocationService.java b/src/main/java/com/huaheng/api/wcs/service/warecellAllocation/LocationAllocationService.java
index 7ac3d6f..8d2c833 100644
--- a/src/main/java/com/huaheng/api/wcs/service/warecellAllocation/LocationAllocationService.java
+++ b/src/main/java/com/huaheng/api/wcs/service/warecellAllocation/LocationAllocationService.java
@@ -9,13 +9,15 @@ public interface LocationAllocationService {
 
 
     String allocation(int high, String area, String roadWay, String containerCode, Integer frequencyLocation,
-                      Integer emptyContainerTask, Integer isSelfCreated, boolean isFlammable, boolean transfer, String taskNo);
+                      Integer emptyContainerTask, Integer isSelfCreated, boolean isFlammable, String taskNo);
 
-    String fiveStacker(int high, String containerCode, boolean isFlammable, boolean transfer, String taskNo);
+    String fiveStacker(int high, String containerCode, boolean isFlammable, String taskNo);
 
     void setTemporaryLocationType(Location location, boolean isBigContainer);
 
-    String doubleRk(String area, String roadWay, int high, Integer frequencyLocation, Integer emptyContainerTask, boolean isFlammable);
+    String doubleRk(String roadWay, int high, Integer frequencyLocation, Integer emptyContainerTask, boolean isFlammable, String taskNo);
 
     String isSelfCreated(String roadWay, int high, Integer frequencyLocation);
+
+    String isFlammable(String roadWay, int high, Integer frequencyLocation, String taskNo);
 }
diff --git a/src/main/java/com/huaheng/api/wcs/service/warecellAllocation/LocationAllocationServiceImpl.java b/src/main/java/com/huaheng/api/wcs/service/warecellAllocation/LocationAllocationServiceImpl.java
index 62276fb..b39e2f8 100644
--- a/src/main/java/com/huaheng/api/wcs/service/warecellAllocation/LocationAllocationServiceImpl.java
+++ b/src/main/java/com/huaheng/api/wcs/service/warecellAllocation/LocationAllocationServiceImpl.java
@@ -57,15 +57,17 @@ public class LocationAllocationServiceImpl implements LocationAllocationService 
     @Override
     @Transactional(rollbackFor = Exception.class)
     public String allocation(int high, String area, String roadWay, String containerCode, Integer frequencyLocation,
-                             Integer emptyContainerTask, Integer isSelfCreated, boolean isFlammable, boolean transfer, String taskNo) {
+                             Integer emptyContainerTask, Integer isSelfCreated, boolean isFlammable, String taskNo) {
 
-        //二期5号巷道
-        if (roadWay.equals(DYNAMIC_ROADWAY)) {
-            return locationAllocationService.fiveStacker(high, containerCode, isFlammable, transfer, taskNo);
+
+        if (roadWay.equals(DYNAMIC_ROADWAY)) {//二期5号巷道
+            return locationAllocationService.fiveStacker(high, containerCode, isFlammable, taskNo);
         } else if (isSelfCreated == 1) { //二厂的自建单据库位
             return locationAllocationService.isSelfCreated(roadWay, high, frequencyLocation);
+        } else if (isFlammable) { //可燃物料
+            return locationAllocationService.isFlammable(roadWay, high, frequencyLocation, taskNo);
         } else {
-            return locationAllocationService.doubleRk(area, roadWay, high, frequencyLocation, emptyContainerTask, isFlammable);
+            return locationAllocationService.doubleRk(roadWay, high, frequencyLocation, emptyContainerTask, isFlammable, taskNo);
         }
     }
 
@@ -74,7 +76,7 @@ public class LocationAllocationServiceImpl implements LocationAllocationService 
     //分配库位排序,(层-外侧-内侧-列)
     @Override
     @Transactional(rollbackFor = Exception.class)
-    public String fiveStacker(int high, String containerCode, boolean isFlammable, boolean transfer, String taskNo) {
+    public String fiveStacker(int high, String containerCode, boolean isFlammable, String taskNo) {
         boolean entry = false;//入库任务
         TaskHeader taskHeader = taskHeaderService.getById(taskNo);
         if (taskHeader != null) {//空托盘入库和整托入库
@@ -249,7 +251,18 @@ public class LocationAllocationServiceImpl implements LocationAllocationService 
      */
     @Override
     @Transactional(rollbackFor = Exception.class)
-    public String doubleRk(String area, String roadWay, int high, Integer frequencyLocation, Integer emptyContainerTask, boolean isFlammable) {
+    public String doubleRk(String roadWay, int high, Integer frequencyLocation, Integer emptyContainerTask, boolean isFlammable, String taskNo) {
+        boolean SORTINGSHIPMENT = false;//分拣任务回库不需要判断预留库位
+        TaskHeader taskHeader = taskHeaderService.getById(taskNo);
+        if (taskHeader != null) {
+            if (taskHeader.getTaskType().equals(TASK_TYPE_SORTINGSHIPMENT)) {
+                SORTINGSHIPMENT = true;
+            }
+        }
+        int reserveNumber = 0;
+        if (!SORTINGSHIPMENT) {
+            reserveNumber = getReserveNumber();
+        }
         //如果是二厂的空托盘入库任务,优先分配空托盘库位,没有了再分配其他的库位
         if (emptyContainerTask == 1) {
             LambdaQueryWrapper<Location> wrapper = Wrappers.lambdaQuery();
@@ -264,7 +277,6 @@ public class LocationAllocationServiceImpl implements LocationAllocationService 
             }
         }
 
-        int reserveNumber = getReserveNumber();// 获取双伸位预留库位数
         // 移除掉可用库位数小于预留库位数的巷道
         LambdaQueryWrapper<Location> wrapper = Wrappers.lambdaQuery();
         wrapper.eq(Location::getRoadway, roadWay)
@@ -290,30 +302,11 @@ public class LocationAllocationServiceImpl implements LocationAllocationService 
                 .eq(Location::getContainerCode, "")
                 .eq(Location::getSelfCreated, NO_TSELFCREATED)
                 .eq(Location::getOnlyEmptyContainer, NO_EMPTY_CONTAINER_LOCATION)
+                .orderByAsc(Location::getHigh)
+                .orderByAsc(Location::getILayer)
+                .orderByAsc(Location::getId)
                 .last(" limit 20");
 
-        //频繁库位
-        String str;
-        if (frequencyLocation == 1) {
-            str = "frequencyLocation asc";
-            //locationLambda.orderByAsc(Location::getFrequencyLocation); //升序
-        } else if (frequencyLocation == 2) {
-            //常用
-            locationLambda.ge(Location::getFrequencyLocation, 2);//大于等于2
-            str = "frequencyLocation asc";
-            //locationLambda.orderByAsc(Location::getFrequencyLocation);
-        } else {
-            //不常用
-            str = "frequencyLocation desc";
-            //locationLambda.orderByDesc(Location::getFrequencyLocation);//倒序
-        }
-
-        //可燃物料
-        if (isFlammable) {
-            locationLambda.orderByAsc(Location::getILayer);
-        } else {
-            locationLambda.last("ORDER BY " + str + ", (CASE WHEN iLayer > 2 THEN iLayer ELSE iLayer + 20 END) ASC");
-        }
         List<Location> locationList = locationService.list(locationLambda);
         List<Location> removeLocaationList = new ArrayList<>();
         if (locationList != null && !locationList.isEmpty()) {
@@ -338,25 +331,11 @@ public class LocationAllocationServiceImpl implements LocationAllocationService 
                     .eq(Location::getContainerCode, "")
                     .eq(Location::getSelfCreated, NO_TSELFCREATED)
                     .eq(Location::getOnlyEmptyContainer, NO_EMPTY_CONTAINER_LOCATION)
+                    .orderByAsc(Location::getHigh)
+                    .orderByAsc(Location::getILayer)
+                    .orderByAsc(Location::getId)
                     .last(" limit 20");
 
-            //频繁库位
-            //if (frequencyLocation == 1) {
-            //    locationLambda.orderByAsc(Location::getFrequencyLocation); //升序
-            //} else if (frequencyLocation == 2) {
-            //    //常用
-            //    locationLambda.ge(Location::getFrequencyLocation, 2);//大于等于2
-            //    locationLambda.orderByAsc(Location::getFrequencyLocation);
-            //} else {
-            //    //不常用
-            //    locationLambda.orderByDesc(Location::getFrequencyLocation);//倒序
-            //}
-            //可燃物料(空托盘不用进来判断)
-            if (isFlammable) {
-                locationLambda.orderByAsc(Location::getILayer);
-            } else {
-                locationLambda.last("ORDER BY " + str + ", (CASE WHEN iLayer > 2 THEN iLayer ELSE iLayer + 20 END) ASC");
-            }
             locationList = locationService.list(locationLambda);
             removeLocaationList = new ArrayList<>();
             if (locationList != null && !locationList.isEmpty()) {
@@ -378,13 +357,15 @@ public class LocationAllocationServiceImpl implements LocationAllocationService 
         return location.getCode();
     }
 
+
     //自建单据
     @Override
     public String isSelfCreated(String roadWay, int high, Integer frequencyLocation) {
         int reserveNumber = getReserveNumber();// 获取双伸位预留库位数
         // 移除掉可用库位数小于预留库位数的巷道
         LambdaQueryWrapper<Location> wrapper = Wrappers.lambdaQuery();
-        wrapper.eq(Location::getRoadway, roadWay)
+        wrapper
+                .eq(Location::getRoadway, roadWay)
                 .eq(Location::getStatus, STATUS_LOCATION_EMPTY)
                 .eq(Location::getHigh, high)
                 .eq(Location::getContainerCode, "")
@@ -407,6 +388,9 @@ public class LocationAllocationServiceImpl implements LocationAllocationService 
                 .eq(Location::getContainerCode, "")
                 .eq(Location::getSelfCreated, SELFCREATED)
                 .eq(Location::getOnlyEmptyContainer, NO_EMPTY_CONTAINER_LOCATION)
+                .orderByAsc(Location::getHigh)
+                .orderByAsc(Location::getILayer)
+                .orderByAsc(Location::getId)
                 .last(" limit 20");
 
 
@@ -427,13 +411,17 @@ public class LocationAllocationServiceImpl implements LocationAllocationService 
         // 如果没有外侧库位可分配了,再查内侧的库位
         if (locationList == null || locationList.isEmpty()) {
             locationLambda = Wrappers.lambdaQuery();
-            locationLambda.eq(StringUtils.isNotEmpty(roadWay), Location::getRoadway, roadWay)
+            locationLambda
+                    .eq(StringUtils.isNotEmpty(roadWay), Location::getRoadway, roadWay)
                     .eq(Location::getStatus, STATUS_LOCATION_EMPTY)
                     .eq(Location::getHigh, high)
                     .eq(Location::getRowFlag, ROW_IN)
                     .eq(Location::getContainerCode, "")
                     .eq(Location::getSelfCreated, SELFCREATED)
                     .eq(Location::getOnlyEmptyContainer, NO_EMPTY_CONTAINER_LOCATION)
+                    .orderByAsc(Location::getHigh)
+                    .orderByAsc(Location::getILayer)
+                    .orderByAsc(Location::getId)
                     .last(" limit 20");
 
             locationList = locationService.list(locationLambda);
@@ -458,6 +446,97 @@ public class LocationAllocationServiceImpl implements LocationAllocationService 
     }
 
 
+    //可燃物料
+    @Override
+    public String isFlammable(String roadWay, int high, Integer frequencyLocation, String taskNo) {
+        int flammableLayer = 3;
+
+        boolean SORTINGSHIPMENT = false;//分拣任务回库不需要判断预留库位
+        TaskHeader taskHeader = taskHeaderService.getById(taskNo);
+        if (taskHeader != null) {
+            if (taskHeader.getTaskType().equals(TASK_TYPE_SORTINGSHIPMENT)) {
+                SORTINGSHIPMENT = true;
+            }
+        }
+        int reserveNumber = 0;
+        if (!SORTINGSHIPMENT) {
+            reserveNumber = getReserveNumber();
+        }
+
+        // 移除掉可用库位数小于预留库位数的巷道
+        LambdaQueryWrapper<Location> wrapper = Wrappers.lambdaQuery();
+        wrapper.eq(Location::getRoadway, roadWay)
+                .eq(Location::getStatus, STATUS_LOCATION_EMPTY)
+                .eq(Location::getHigh, high)
+                .eq(Location::getContainerCode, "")
+                .eq(Location::getSelfCreated, NO_TSELFCREATED)
+                .eq(Location::getOnlyEmptyContainer, NO_EMPTY_CONTAINER_LOCATION)
+                .last(" limit 20");
+
+        List<Location> totalLocationList = locationService.list(wrapper);
+        //双伸位预留库位数不够了就排除掉该巷道
+        if (totalLocationList.size() <= reserveNumber) {
+            return "可能是库位不够用了,请检查预留库位数";
+        }
+
+        // 查找外侧的库位
+        LambdaQueryWrapper<Location> locationLambda = Wrappers.lambdaQuery();
+        locationLambda.eq(Location::getRoadway, roadWay)
+                .eq(Location::getStatus, STATUS_LOCATION_EMPTY)
+                .eq(Location::getHigh, high)
+                .eq(Location::getRowFlag, ROW_OUT)//外侧
+                .eq(Location::getContainerCode, "")
+                .eq(Location::getSelfCreated, NO_TSELFCREATED)
+                .eq(Location::getOnlyEmptyContainer, NO_EMPTY_CONTAINER_LOCATION)
+                .last("ORDER BY (CASE WHEN iLayer > " + flammableLayer + " THEN iLayer ELSE iLayer + 20 END) ASC LIMIT 20");
+
+        List<Location> locationList = locationService.list(locationLambda);
+        List<Location> removeLocaationList = new ArrayList<>();
+        if (locationList != null && !locationList.isEmpty()) {
+            for (Location location1 : locationList) {
+                //库位内侧,有未完成的任务就去掉这个库位
+                if (taskHeaderService.getUncompleteTaskInNear(location1) > 0) {
+                    removeLocaationList.add(location1);
+                }
+            }
+        }
+        if (locationList != null) {
+            locationList.removeAll(removeLocaationList);
+        }
+
+        // 如果没有外侧库位可分配了,再查内侧的库位
+        if (locationList == null || locationList.isEmpty()) {
+            locationLambda = Wrappers.lambdaQuery();
+            locationLambda.eq(StringUtils.isNotEmpty(roadWay), Location::getRoadway, roadWay)
+                    .eq(Location::getStatus, STATUS_LOCATION_EMPTY)
+                    .eq(Location::getHigh, high)
+                    .eq(Location::getRowFlag, ROW_IN)
+                    .eq(Location::getContainerCode, "")
+                    .eq(Location::getSelfCreated, NO_TSELFCREATED)
+                    .eq(Location::getOnlyEmptyContainer, NO_EMPTY_CONTAINER_LOCATION)
+                    .last("ORDER BY (CASE WHEN iLayer > " + flammableLayer + " THEN iLayer ELSE iLayer + 20 END) ASC LIMIT 20");
+            locationList = locationService.list(locationLambda);
+            removeLocaationList = new ArrayList<>();
+            if (locationList != null && !locationList.isEmpty()) {
+                for (Location location1 : locationList) {
+                    if (taskHeaderService.getUncompleteTaskInNear(location1) > 0) {
+                        removeLocaationList.add(location1);
+                    }
+                }
+            }
+            if (locationList != null) {
+                locationList.removeAll(removeLocaationList);
+            }
+        }
+        // 如果没有符合条件的库位可分配,返回null
+        if (locationList == null || locationList.isEmpty()) {
+            return null;
+        }
+        Location location = locationList.stream().findFirst().orElse(null);
+        return location.getCode();
+    }
+
+
     //获取双伸位预留库位数
     private int getReserveNumber() {
         String value = configService.getKey(DOUBLE_FORK_RESERVE_LOCATION);
@@ -471,6 +550,20 @@ public class LocationAllocationServiceImpl implements LocationAllocationService 
         return StringUtils.isNotEmpty(value) ? Integer.parseInt(value) : 0;
     }
 
+
+    //频繁库位
+    //if (frequencyLocation == 1) {
+    //    locationLambda.orderByAsc(Location::getFrequencyLocation); //升序
+    //} else if (frequencyLocation == 2) {
+    //    //常用
+    //    locationLambda.ge(Location::getFrequencyLocation, 2);//大于等于2
+    //    locationLambda.orderByAsc(Location::getFrequencyLocation);
+    //} else {
+    //    //不常用
+    //    locationLambda.orderByDesc(Location::getFrequencyLocation);//倒序
+    //}
+
+
     /**
      * 单伸位库位入库分配库位
      */
diff --git a/src/main/java/com/huaheng/api/wcs/service/warecellAllocation/WarecellAllocationServiceImpl.java b/src/main/java/com/huaheng/api/wcs/service/warecellAllocation/WarecellAllocationServiceImpl.java
index 5e9866b..5a7fcdd 100644
--- a/src/main/java/com/huaheng/api/wcs/service/warecellAllocation/WarecellAllocationServiceImpl.java
+++ b/src/main/java/com/huaheng/api/wcs/service/warecellAllocation/WarecellAllocationServiceImpl.java
@@ -213,7 +213,7 @@ public class WarecellAllocationServiceImpl implements WarecellAllocationService 
         //巷道
         String roadWay = roadWays.get(0);
         //分配库位
-        locationCode = locationAllocationService.allocation(high, area, roadWay, containerCode, frequencyLocation, emptyContainerTask, isSelfCreated, isFlammable, false, taskNo);
+        locationCode = locationAllocationService.allocation(high, area, roadWay, containerCode, frequencyLocation, emptyContainerTask, isSelfCreated, isFlammable, taskNo);
 
         if (StringUtils.isEmpty(locationCode)) {
             return AjaxResult.error("没有库位可分配");
@@ -258,7 +258,7 @@ public class WarecellAllocationServiceImpl implements WarecellAllocationService 
                 Location destinationLocation;
                 if (roadWay.equals("5") || isSelfCreated == 1) {//5号巷道、自建单据库位
                     //分配库位
-                    String destinationLocationCode = locationAllocationService.allocation(high, area, roadWay, containerCode, frequencyLocation, emptyContainerTask, isSelfCreated, isFlammable, true, taskNo);
+                    String destinationLocationCode = locationAllocationService.allocation(high, area, roadWay, containerCode, frequencyLocation, emptyContainerTask, isSelfCreated, isFlammable, taskNo);
                     if (StringUtils.isEmpty(destinationLocationCode)) {
                         return AjaxResult.error("移库没有剩余库位");
                     } else if (destinationLocationCode.length() > 10) {
diff --git a/src/main/java/com/huaheng/pc/config/location/controller/LocationController.java b/src/main/java/com/huaheng/pc/config/location/controller/LocationController.java
index f4621e7..4b92dcd 100644
--- a/src/main/java/com/huaheng/pc/config/location/controller/LocationController.java
+++ b/src/main/java/com/huaheng/pc/config/location/controller/LocationController.java
@@ -45,7 +45,9 @@ import javax.annotation.Resource;
 import javax.sql.DataSource;
 import java.math.BigDecimal;
 import java.util.ArrayList;
+import java.util.HashMap;
 import java.util.List;
+import java.util.Map;
 import java.util.stream.Collectors;
 
 @Api(tags = {"库位操作类"})
@@ -310,7 +312,6 @@ public class LocationController extends BaseController {
                 .eq(StringUtils.isNotEmpty(type), Location::getLocationType, type)
                 .eq(StringUtils.isNotEmpty(type), Location::getZoneCode, type);
         List<Location> locations = locationService.list(locationLambdaQueryWrapper);
-
         List<InventoryDetail> inventoryDetailList = inventoryDetailService.list();
 
         for (Location location1 : locations) {
@@ -327,7 +328,6 @@ public class LocationController extends BaseController {
             String status = location1.getStatus();
             String containerCode = location1.getContainerCode();
             List<String> materialNameList = inventoryDetails.stream().map(InventoryDetail::getMaterialName).collect(Collectors.toList());
-            List<String> batchList = inventoryDetails.stream().map(InventoryDetail::getBatch).collect(Collectors.toList());
             List<String> materialCodeList = inventoryDetails.stream().map(InventoryDetail::getMaterialCode).collect(Collectors.toList());
             List<BigDecimal> qtyList = inventoryDetails.stream().map(InventoryDetail::getQty).collect(Collectors.toList());
             if (QuantityConstant.STATUS_LOCATION_EMPTY.equals(status)) {
@@ -339,7 +339,6 @@ public class LocationController extends BaseController {
                     } else {
                         location1.setMaterialName(materialNameList);
                         location1.setMaterialCode(materialCodeList);
-                        location1.setBatch(batchList);
                         location1.setQty(qtyList);
                         userDef3 = LocationStatus.IDLE_FULL_CONTAINER;
                     }
@@ -353,7 +352,6 @@ public class LocationController extends BaseController {
                     } else {
                         location1.setMaterialName(materialNameList);
                         location1.setMaterialCode(materialCodeList);
-                        location1.setBatch(batchList);
                         location1.setQty(qtyList);
                         userDef3 = LocationStatus.LOCK_FULL_CONTAINER;
                     }
@@ -367,7 +365,6 @@ public class LocationController extends BaseController {
                     } else {
                         location1.setMaterialName(materialNameList);
                         location1.setMaterialCode(materialCodeList);
-                        location1.setBatch(batchList);
                         location1.setQty(qtyList);
                         userDef3 = LocationStatus.DISABLE_FULL_CONTAINER;
                     }
@@ -383,7 +380,6 @@ public class LocationController extends BaseController {
                     } else {
                         location1.setMaterialName(materialNameList);
                         location1.setMaterialCode(materialCodeList);
-                        location1.setBatch(batchList);
                         location1.setQty(qtyList);
                         userDef3 = LocationStatus.DISABLE_FULL_CONTAINER;
                     }
diff --git a/src/main/java/com/huaheng/pc/shipment/shipmentHeader/controller/ShipmentHeaderController.java b/src/main/java/com/huaheng/pc/shipment/shipmentHeader/controller/ShipmentHeaderController.java
index 64be55e..c93cd48 100644
--- a/src/main/java/com/huaheng/pc/shipment/shipmentHeader/controller/ShipmentHeaderController.java
+++ b/src/main/java/com/huaheng/pc/shipment/shipmentHeader/controller/ShipmentHeaderController.java
@@ -133,6 +133,7 @@ public class ShipmentHeaderController extends BaseController {
     public TableDataInfo list(ShipmentHeader shipmentHeader, String createdBegin, String createdEnd, String deliveryDate,
                               @ApiParam(name = "completeTimeBegin", value = "开始时间") String completeTimeBegin,
                               @ApiParam(name = "completeTimeEnd", value = "完成时间") String completeTimeEnd,
+                              String warehouseTypeDocument,
                               String startDate, String importDate, String isAsc) {
         LambdaQueryWrapper<ShipmentHeader> lambdaQueryWrapper = Wrappers.lambdaQuery();
         PageDomain pageDomain = TableSupport.buildPageRequest();
@@ -229,7 +230,6 @@ public class ShipmentHeaderController extends BaseController {
                 //物料搜索
                 .inSql(StringUtils.isNotEmpty(shipmentHeader.getMaterialName()), ShipmentHeader::getId, "SELECT shipmentId FROM shipment_detail WHERE materialName LIKE '%" + shipmentHeader.getMaterialName() + "%'")
                 .inSql(StringUtils.isNotEmpty(shipmentHeader.getMaterialCode()), ShipmentHeader::getId, "SELECT shipmentId FROM shipment_detail WHERE materialCode LIKE '%" + shipmentHeader.getMaterialCode() + "%'")
-
                 .orderByAsc(ShipmentHeader::getLastStatus)
                 .orderByAsc(ShipmentHeader::getRequestedStartDate)
                 .orderByAsc(ShipmentHeader::getCreated);
@@ -237,13 +237,43 @@ public class ShipmentHeaderController extends BaseController {
         if (StringUtils.isNotNull(pageNum) && StringUtils.isNotNull(pageSize)) {
             Page<ShipmentHeader> page = new Page<>(pageNum, pageSize);
             IPage<ShipmentHeader> iPage = shipmentHeaderService.page(page, lambdaQueryWrapper);
-            return getMpDataTable(iPage.getRecords(), iPage.getTotal());
+            //仓库类型单据过滤
+            if (StringUtils.isNotEmpty(warehouseTypeDocument)) {
+                List<ShipmentHeader> list = warehouseTypeDocumentFilter(iPage.getRecords(), warehouseTypeDocument);
+                return getMpDataTable(list, iPage.getTotal());
+            } else {
+                return getMpDataTable(iPage.getRecords(), iPage.getTotal());
+            }
+
         } else {
             List<ShipmentHeader> list = shipmentHeaderService.list(lambdaQueryWrapper);
             return getDataTable(list);
         }
     }
 
+    private List<ShipmentHeader> warehouseTypeDocumentFilter(List<ShipmentHeader> shipmentHeaderList, String warehouseTypeDocument) {
+        List<ShipmentHeader> list = new ArrayList<>();
+        for (ShipmentHeader shipmentHeader : shipmentHeaderList) {
+            List<ShipmentDetail> shipmentDetailList = shipmentDetailService.list(new LambdaQueryWrapper<ShipmentDetail>().eq(ShipmentDetail::getShipmentId, shipmentHeader.getId()));
+
+            for (ShipmentDetail shipmentDetail : shipmentDetailList) {
+                if (warehouseTypeDocument.equals("0")) {//立库
+                    List<InventoryDetail> inventoryDetails = inventoryDetailService.list(new LambdaQueryWrapper<InventoryDetail>().eq(InventoryDetail::getMaterialCode, shipmentDetail.getMaterialCode()).eq(InventoryDetail::getZoneCode, "L"));
+                    if (!inventoryDetails.isEmpty()) {
+                        list.add(shipmentHeader);
+                        break;
+                    }
+                } else {//平库
+                    List<InventoryDetail> inventoryDetails = inventoryDetailService.list(new LambdaQueryWrapper<InventoryDetail>().eq(InventoryDetail::getMaterialCode, shipmentDetail.getMaterialCode()).ne(InventoryDetail::getZoneCode, "L"));
+                    if (!inventoryDetails.isEmpty()) {
+                        list.add(shipmentHeader);
+                    }
+                }
+            }
+        }
+        return list;
+    }
+
     /**
      * 新增出库单主
      */
diff --git a/src/main/java/com/huaheng/pc/shipment/shipmentHeader/domain/ShipmentPrintVo.java b/src/main/java/com/huaheng/pc/shipment/shipmentHeader/domain/ShipmentPrintVo.java
index 0c29dd5..358261f 100644
--- a/src/main/java/com/huaheng/pc/shipment/shipmentHeader/domain/ShipmentPrintVo.java
+++ b/src/main/java/com/huaheng/pc/shipment/shipmentHeader/domain/ShipmentPrintVo.java
@@ -35,7 +35,13 @@ public class ShipmentPrintVo {
         data.unionCode = unionCode;//合并单号
         data.recordCode = shipmentHeader.getRecordCode();//合并前单号
         data.zoneInfo = zoneInfo;//库区
-        data.materialColor = shipmentHeader.getMaterialColor().substring(12);//颜色
+        String materialColor = shipmentHeader.getMaterialColor();
+        if (materialColor.length() > 12) {
+            data.materialColor = materialColor.substring(12);
+        } else {
+            data.materialColor = materialColor;
+        }
+
         data.pageNumber = pageNumber;//页码
         if (shipmentHeader.getShipmentType().equals("208")) {
             data.footRight = "形态转换单据得重新维护编码,并重新入库";
@@ -62,7 +68,12 @@ public class ShipmentPrintVo {
         voDetail.roadway = roadway;//巷道
         voDetail.recordCode = taskDetail.getRecordCode();//合并前单号
         voDetail.port = port;//出库口
-        voDetail.materialColor = taskDetail.getMaterialColor();//颜色
+        String materialColor = taskDetail.getMaterialColor();
+        if (materialColor.length() > 12) {
+            data.materialColor = materialColor.substring(12);
+        } else {
+            data.materialColor = materialColor;
+        }
         voDetail.paintStatus = taskDetail.getPaintStatus();//喷漆状态
         data.details.add(voDetail);
         return voDetail;
diff --git a/src/main/resources/templates/shipment/shipmentHeader/shipmentHeader.html b/src/main/resources/templates/shipment/shipmentHeader/shipmentHeader.html
index 35ef1c6..e449b35 100644
--- a/src/main/resources/templates/shipment/shipmentHeader/shipmentHeader.html
+++ b/src/main/resources/templates/shipment/shipmentHeader/shipmentHeader.html
@@ -49,6 +49,13 @@
                                                 th:value="${e['dictValue']}"></option>
                                     </select>
                                     </li>
+                                    <!--                                    <li>-->
+                                    <!--                                        仓库类型单据:<select id="warehouseTypeDocument" name="warehouseTypeDocument">-->
+                                    <!--                                        <option value="">所有</option>-->
+                                    <!--                                        <option value="0">立库</option>-->
+                                    <!--                                        <option value="1">平库</option>-->
+                                    <!--                                    </select>-->
+                                    <!--                                    </li>-->
                                     <li>
                                         生产车间:<input type="text" name="workshop"/>
                                     </li>