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 eab5af1..0bc039c 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
@@ -4,10 +4,13 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 import com.huaheng.api.wcs.domain.TaskFinishDomain;
 import com.huaheng.api.wcs.domain.WcsTask;
+import com.huaheng.api.wcs.service.warecellAllocation.WarecellAllocationService;
 import com.huaheng.common.exception.service.ServiceException;
 import com.huaheng.common.utils.StringUtils;
 import com.huaheng.common.utils.security.ShiroUtils;
 import com.huaheng.framework.web.domain.AjaxResult;
+import com.huaheng.pc.config.FilterConfigDetail.domain.FilterConfigDetail;
+import com.huaheng.pc.config.FilterConfigDetail.service.FilterConfigDetailService;
 import com.huaheng.pc.config.location.domain.Location;
 import com.huaheng.pc.config.location.service.LocationService;
 import com.huaheng.pc.receipt.receiptContainerDetail.domain.ReceiptContainerDetail;
@@ -22,6 +25,7 @@ import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
+import javax.annotation.Resource;
 import java.util.ArrayList;
 import java.util.List;
 
@@ -39,6 +43,10 @@ public class OverrideHandleServiceImpl implements OverrideHandleService {
     private ReceiptContainerHeaderService receiptContainerHeaderService;
     @Autowired
     private ReceiptContainerDetailService receiptContainerDetailService;
+    @Resource
+    private WarecellAllocationService warecellAllocationService;
+    @Resource
+    private FilterConfigDetailService filterConfigDetailService;
 
     /**
      * 重入处理
@@ -60,7 +68,7 @@ public class OverrideHandleServiceImpl implements OverrideHandleService {
             return AjaxResult.error("目的库位为空");
         }
         if(StringUtils.isEmpty(taskFinishDomain.getRedirectionLocationCode())){
-            return AjaxResult.error("目的库位为空");
+            return AjaxResult.error("重入的库位编码为空");
         }
 
 
@@ -105,7 +113,26 @@ public class OverrideHandleServiceImpl implements OverrideHandleService {
             }
         }else {
             //重入的库位由wms提供
+            //查询任务明细
+            LambdaQueryWrapper<TaskDetail> taskDetailLambda = Wrappers.lambdaQuery();
+            taskDetailLambda.eq(TaskDetail::getTaskId, taskFinishDomain.getTaskNo());
+            List<TaskDetail> taskDetailList = taskDetailService.list(taskDetailLambda);
+            //查询入库组盘明细
+            List<ReceiptContainerDetail> receiptContainerDetailList = new ArrayList<>();
+            for (TaskDetail taskDetail : taskDetailList) {
+                receiptContainerDetailList.add(receiptContainerDetailService.getById(taskDetail.getAllocationId()));
+            }
+            ReceiptContainerHeader receiptContainerHeader = receiptContainerHeaderService.getById(receiptContainerDetailList.get(0).getReceiptContainerId());
+            String locatingRule = warecellAllocationService.taskPositioning(receiptContainerDetailList.get(0));
+
+            LambdaQueryWrapper<FilterConfigDetail> filterConfigDetailLambda = Wrappers.lambdaQuery();
+            filterConfigDetailLambda.eq(FilterConfigDetail::getCode, locatingRule);
+            FilterConfigDetail filterConfigDetail = filterConfigDetailService.getOne(filterConfigDetailLambda);
 
+            //根据定位规则查询库位编码
+            LambdaQueryWrapper<Location> locationLambda = Wrappers.lambdaQuery();
+            locationLambda.last(filterConfigDetail.getStatement());
+            newlocation = locationService.getOne(locationLambda);
         }
 
         //修改任务
diff --git a/src/main/java/com/huaheng/api/wcs/service/warecellAllocation/WarecellAllocationService.java b/src/main/java/com/huaheng/api/wcs/service/warecellAllocation/WarecellAllocationService.java
index 62623f0..5527afd 100644
--- a/src/main/java/com/huaheng/api/wcs/service/warecellAllocation/WarecellAllocationService.java
+++ b/src/main/java/com/huaheng/api/wcs/service/warecellAllocation/WarecellAllocationService.java
@@ -2,9 +2,12 @@ package com.huaheng.api.wcs.service.warecellAllocation;
 
 import com.huaheng.api.wcs.domain.WcsTask;
 import com.huaheng.framework.web.domain.AjaxResult;
+import com.huaheng.pc.receipt.receiptContainerDetail.domain.ReceiptContainerDetail;
 
 public interface WarecellAllocationService {
 
     //仓位分配
     AjaxResult WarecellAllocation(WcsTask wcsTask);
+
+    String taskPositioning(ReceiptContainerDetail receiptContainerDetail);
 }
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 18abb7c..e465050 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
@@ -35,6 +35,7 @@ import com.huaheng.pc.task.taskDetail.service.TaskDetailService;
 import com.huaheng.pc.task.taskHeader.domain.TaskHeader;
 import com.huaheng.pc.task.taskHeader.service.TaskHeaderService;
 import com.jhlabs.image.LightFilter;
+import com.mchange.v1.util.Sublist;
 import io.swagger.annotations.ResponseHeader;
 import org.springframework.stereotype.Service;
 
@@ -129,48 +130,12 @@ public class WarecellAllocationServiceImpl implements WarecellAllocationService 
 
         for (ReceiptContainerDetail receiptContainerDetail : receiptContainerDetailList) {
             ReceiptContainerHeader receiptContainerHeader = receiptContainerHeaderService.getById(receiptContainerDetail.getReceiptContainerId());
-            String locatingRule = receiptContainerHeader.getLocatingRule(); //定位规则
-            if (StringUtils.isEmpty(locatingRule)){
-                locatingRule = receiptDetailService.getById(receiptContainerDetail.getReceiptDetailId()).getLocatingRule();
-                //入库单明细定位规则不为空时执行
-                if (StringUtils.isEmpty(locatingRule)){
-                    //入库单明细为空时,查询物料表中是否含有定位规则
-                    LambdaQueryWrapper<Material> materialLambda = Wrappers.lambdaQuery();
-                    materialLambda.eq(Material::getCode, receiptContainerDetail.getMaterialCode());
-                    Material material = materialService.getOne(materialLambda);
-                    locatingRule = material.getLocatingRule();
 
-                    if (StringUtils.isEmpty(locatingRule)){
-                        //物料表中定位规则为空时,查询物料类别
-                        LambdaQueryWrapper<MaterialType> materialTypeLambda = Wrappers.lambdaQuery();
-                        materialTypeLambda.eq(MaterialType::getCode, material.getType());
-                        MaterialType materialType = materialTypeService.getOne(materialTypeLambda);
-                        locatingRule = materialType.getLocatingRule();
-                        if (StringUtils.isEmpty(locatingRule)){
-                            //物料类别中定位规则为空时,查询入库首选项
-                            LambdaQueryWrapper<ConfigValue> configValueLambda = Wrappers.lambdaQuery();
-                            configValueLambda.eq(ConfigValue::getWarehouseCode, ShiroUtils.getWarehouseCode())
-                                    .eq(ConfigValue::getModuleType, "receipt")
-                                    .eq(ConfigValue::getRecordType, "入库首选项");
-                            ConfigValue configValue = configValueService.getOne(configValueLambda);
-                            LambdaQueryWrapper<ReceiptPreference> receiptPreferenceLambda = Wrappers.lambdaQuery();
-                            receiptPreferenceLambda.eq(ReceiptPreference::getCode, configValue.getValue());
-                            ReceiptPreference receiptPreference = receiptPreferenceService.getOne(receiptPreferenceLambda);
-                            locatingRule = receiptPreferenceService.getOne(receiptPreferenceLambda).getLocationRule();
-                        }
-                    }
-                }
-
-            }
-            //通过定位规则查找自定义sql
-            if (StringUtils.isEmpty(locatingRule)){
-                throw new ServiceException("未绑定定位规则");
-            }
+            String locatingRule = this.taskPositioning(receiptContainerDetail);
 
             LambdaQueryWrapper<FilterConfigDetail> filterConfigDetailLambda = Wrappers.lambdaQuery();
             filterConfigDetailLambda.eq(FilterConfigDetail::getCode, locatingRule);
             FilterConfigDetail filterConfigDetail = filterConfigDetailService.getOne(filterConfigDetailLambda);
-
             String[] locatingRules = filterConfigDetail.getStatement().split("limit");
 
             //根据定位规则查询库位编码
@@ -178,7 +143,7 @@ public class WarecellAllocationServiceImpl implements WarecellAllocationService 
             locationLambda.last(locatingRules[0]);
             List<Location> locationList = locationService.list(locationLambda);
 //            locationList.stream().filter(location -> location.getLocationType().equals(locationTypeList.get(0)));
-            locationCode = filter(locationList, locationTypeList);
+            locationCode = filter(locationList, locationTypeList, wcsTask.getRoadWay());
             if (StringUtils.isEmpty(locationCode)){
                 throw new ServiceException("没有库位可分配");
             }
@@ -205,6 +170,7 @@ public class WarecellAllocationServiceImpl implements WarecellAllocationService 
             }
 
         }
+
         if (StringUtils.isNotEmpty(locationCode)){
             //修改任务明细目标库位
             for (TaskDetail taskDetail : taskDetailList) {
@@ -226,20 +192,65 @@ public class WarecellAllocationServiceImpl implements WarecellAllocationService 
 
     /**
      * 库位筛选
-     * @param locationList
-     * @param locationTypeList
+     * @param locationList 库位列表
+     * @param locationTypeList 库位类型列表
+     * @param roadway 巷道
      * @return
      */
-    public String filter(List<Location> locationList, List<LocationType> locationTypeList){
-        String locationCode = null;
-        for (Location location: locationList){
-            for (LocationType locationType: locationTypeList) {
-                if (location.getLocationType().equals(locationType.getCode())){
-                    locationCode = location.getCode();
-                    return locationCode;
+    public String filter(List<Location> locationList, List<LocationType> locationTypeList, String roadway){
+        List<String> codeList = locationTypeList.stream().map(t-> t.getCode()).collect(Collectors.toList());
+        List<Location> newLocation = locationList.stream().filter(t-> codeList.contains(t.getLocationType()) && t.getRoadway().equals(roadway)).collect(Collectors.toList());
+        if (newLocation.isEmpty()){
+            return null;
+        } else{
+            return newLocation.get(0).getCode();
+        }
+    }
+
+    /**
+     * 定位
+     * @param receiptContainerDetail
+     * @return
+     */
+    public String taskPositioning(ReceiptContainerDetail receiptContainerDetail){
+        ReceiptContainerHeader receiptContainerHeader = receiptContainerHeaderService.getById(receiptContainerDetail.getReceiptContainerId());
+        String locatingRule = receiptContainerHeader.getLocatingRule(); //定位规则
+        if (StringUtils.isEmpty(locatingRule)){
+            locatingRule = receiptDetailService.getById(receiptContainerDetail.getReceiptDetailId()).getLocatingRule();
+            //入库单明细定位规则不为空时执行
+            if (StringUtils.isEmpty(locatingRule)){
+                //入库单明细为空时,查询物料表中是否含有定位规则
+                LambdaQueryWrapper<Material> materialLambda = Wrappers.lambdaQuery();
+                materialLambda.eq(Material::getCode, receiptContainerDetail.getMaterialCode());
+                Material material = materialService.getOne(materialLambda);
+                locatingRule = material.getLocatingRule();
+
+                if (StringUtils.isEmpty(locatingRule)){
+                    //物料表中定位规则为空时,查询物料类别
+                    LambdaQueryWrapper<MaterialType> materialTypeLambda = Wrappers.lambdaQuery();
+                    materialTypeLambda.eq(MaterialType::getCode, material.getType());
+                    MaterialType materialType = materialTypeService.getOne(materialTypeLambda);
+                    locatingRule = materialType.getLocatingRule();
+                    if (StringUtils.isEmpty(locatingRule)){
+                        //物料类别中定位规则为空时,查询入库首选项
+                        LambdaQueryWrapper<ConfigValue> configValueLambda = Wrappers.lambdaQuery();
+                        configValueLambda.eq(ConfigValue::getWarehouseCode, ShiroUtils.getWarehouseCode())
+                                .eq(ConfigValue::getModuleType, "receipt")
+                                .eq(ConfigValue::getRecordType, "入库首选项");
+                        ConfigValue configValue = configValueService.getOne(configValueLambda);
+                        LambdaQueryWrapper<ReceiptPreference> receiptPreferenceLambda = Wrappers.lambdaQuery();
+                        receiptPreferenceLambda.eq(ReceiptPreference::getCode, configValue.getValue());
+                        ReceiptPreference receiptPreference = receiptPreferenceService.getOne(receiptPreferenceLambda);
+                        locatingRule = receiptPreferenceService.getOne(receiptPreferenceLambda).getLocationRule();
+                    }
                 }
             }
         }
-        return null;
+        //通过定位规则查找自定义sql
+        if (StringUtils.isEmpty(locatingRule)){
+            throw new ServiceException("未绑定定位规则");
+        }
+
+        return locatingRule;
     }
 }
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 e26903c..9cc5268 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
@@ -123,7 +123,7 @@ public class LocationController extends BaseController {
     /**
      * 批量新增保存库位
      */
-    @RequiresPermissions("config:location:add")
+    @RequiresPermissions("config:location:addBatch")
     @ApiOperation(value="新增库位", notes="批量新增库位", httpMethod = "POST")
     @Log(title = "通用-库位管理", operating = "新增库位", action = BusinessType.INSERT)
     @PostMapping("/addBatchSave")
diff --git a/src/main/java/com/huaheng/pc/config/location/domain/Location.java b/src/main/java/com/huaheng/pc/config/location/domain/Location.java
index 65c1a0f..1d6f057 100644
--- a/src/main/java/com/huaheng/pc/config/location/domain/Location.java
+++ b/src/main/java/com/huaheng/pc/config/location/domain/Location.java
@@ -7,6 +7,7 @@ import com.baomidou.mybatisplus.annotation.TableName;
 import java.io.Serializable;
 import java.util.Date;
 import lombok.Data;
+import org.springframework.transaction.annotation.Transactional;
 
 @Data
 @TableName(value = "location")
@@ -72,6 +73,12 @@ public class Location implements Serializable {
     private Integer iGrid;
 
     /**
+     * 巷道
+     */
+    @TableField(value = "roadway")
+    private String roadway;
+
+    /**
      * 名称
      */
     @TableField(value = "name")
@@ -174,56 +181,4 @@ public class Location implements Serializable {
     private Boolean deleted;
 
     private static final long serialVersionUID = 1L;
-
-    public static final String COL_CODE = "code";
-
-    public static final String COL_WAREHOUSECODE = "warehouseCode";
-
-    public static final String COL_ZONECODE = "zoneCode";
-
-    public static final String COL_LOCATIONTYPE = "locationType";
-
-    public static final String COL_CONTAINERCODE = "containerCode";
-
-    public static final String COL_IROW = "iRow";
-
-    public static final String COL_ICOLUMN = "iColumn";
-
-    public static final String COL_ILAYER = "iLayer";
-
-    public static final String COL_IGRID = "iGrid";
-
-    public static final String COL_NAME = "name";
-
-    public static final String COL_ENABLE = "enable";
-
-    public static final String COL_LASTCYCLECOUNTDATE = "lastCycleCountDate";
-
-    public static final String COL_CREATED = "created";
-
-    public static final String COL_CREATEDBY = "createdBy";
-
-    public static final String COL_LASTUPDATED = "lastUpdated";
-
-    public static final String COL_LASTUPDATEDBY = "lastUpdatedBy";
-
-    public static final String COL_VERSION = "version";
-
-    public static final String COL_USERDEF1 = "userDef1";
-
-    public static final String COL_USERDEF2 = "userDef2";
-
-    public static final String COL_USERDEF3 = "userDef3";
-
-    public static final String COL_USERDEF4 = "userDef4";
-
-    public static final String COL_USERDEF5 = "userDef5";
-
-    public static final String COL_USERDEF6 = "userDef6";
-
-    public static final String COL_USERDEF7 = "userDef7";
-
-    public static final String COL_USERDEF8 = "userDef8";
-
-    public static final String COL_SYSTEMCREATED = "systemCreated";
 }
\ No newline at end of file
diff --git a/src/main/java/com/huaheng/pc/config/location/service/LocationServiceImpl.java b/src/main/java/com/huaheng/pc/config/location/service/LocationServiceImpl.java
index d616478..3889c72 100644
--- a/src/main/java/com/huaheng/pc/config/location/service/LocationServiceImpl.java
+++ b/src/main/java/com/huaheng/pc/config/location/service/LocationServiceImpl.java
@@ -73,13 +73,18 @@ public class LocationServiceImpl extends ServiceImpl<LocationMapper, Location> i
         return AjaxResult.success("新增库位成功");
     }
 
+    /**
+     * 批量新增库位
+     * @param location
+     * @return boolean
+     */
     @Override
     public boolean insertLocation(Location location) {
         /* 判断库位类型编码是否存在*/
-        LambdaQueryWrapper<LocationType> typelambda = Wrappers.lambdaQuery();
-        typelambda.eq(LocationType::getCode,location.getLocationType())
+        LambdaQueryWrapper<LocationType> typeLambda = Wrappers.lambdaQuery();
+        typeLambda.eq(LocationType::getCode,location.getLocationType())
                         .select(LocationType::getCode);
-        List<Map<String, Object>> list = locationTypeService.listMaps(typelambda);
+        List<Map<String, Object>> list = locationTypeService.listMaps(typeLambda);
         if (list.size() < 1){
             throw new ServiceException("库位类型编码不存在");
         }
@@ -97,6 +102,7 @@ public class LocationServiceImpl extends ServiceImpl<LocationMapper, Location> i
         if(!location.getZoneCode().equals(location.getLocationType())){
             throw new ServiceException(location.getLocationType()+"的库位类型与"+location.getZoneCode()+"库区不匹配");
         }
+
         String prefix = location.getLocationType().substring(1);
         List<Location> locations = new ArrayList<>();
         for (int i=1; i<=location.getIRow().intValue(); i++)  {
@@ -109,6 +115,7 @@ public class LocationServiceImpl extends ServiceImpl<LocationMapper, Location> i
                         param.setIColumn(j);
                         param.setILayer(k);
                         param.setIGrid(m);
+                        param.setRoadway(location.getRoadway());
                         param.setZoneCode(location.getZoneCode());
                         param.setLocationType(location.getLocationType());
                         param.setStatus(location.getStatus());
@@ -121,6 +128,7 @@ public class LocationServiceImpl extends ServiceImpl<LocationMapper, Location> i
                                 String.format("%02d", j),
                                 String.format("%02d", k),
                                 String.format("%02d", m));
+                        //查询该库位编码是否存在
                         LambdaQueryWrapper<Location> queryWrapper = Wrappers.lambdaQuery();
                         queryWrapper.eq(Location::getCode,code)
                                 .eq(Location::getWarehouseCode,ShiroUtils.getWarehouseCode());
@@ -133,8 +141,7 @@ public class LocationServiceImpl extends ServiceImpl<LocationMapper, Location> i
                 }
             }
         }
-        Boolean result = locationService.saveBatch(locations);
-        return result;
+        return locationService.saveBatch(locations);
     }
 
     @Override
diff --git a/src/main/java/com/huaheng/pc/inventory/cycleCountDetail/controller/CycleCountDetailController.java b/src/main/java/com/huaheng/pc/inventory/cycleCountDetail/controller/CycleCountDetailController.java
index 034ac2d..7050705 100644
--- a/src/main/java/com/huaheng/pc/inventory/cycleCountDetail/controller/CycleCountDetailController.java
+++ b/src/main/java/com/huaheng/pc/inventory/cycleCountDetail/controller/CycleCountDetailController.java
@@ -109,10 +109,14 @@ public class CycleCountDetailController extends BaseController {
             //分页查询
             Page<CycleCountDetail> page = new Page<>(pageNum, pageSize);
             IPage<CycleCountDetail> iPage = cycleCountDetailService.page(page, lambdaQueryWrapper);
-            return getMpDataTable(iPage.getRecords(), iPage.getTotal());
+            //根据盘点首选项确定显示字段
+            List<CycleCountDetail> ipages = cycleCountDetailService.preferenceRealize(iPage.getRecords()) ;
+            return getMpDataTable(ipages, iPage.getTotal());
         } else {
             List<CycleCountDetail> list  = cycleCountDetailService.list(lambdaQueryWrapper);
-            return getDataTable(list);
+            //根据盘点首选项确定显示字段
+            List<CycleCountDetail> cycleCountDetails = cycleCountDetailService.preferenceRealize(list) ;
+            return getDataTable(cycleCountDetails);
         }
     }
         //空List
diff --git a/src/main/java/com/huaheng/pc/inventory/cycleCountDetail/service/CycleCountDetailService.java b/src/main/java/com/huaheng/pc/inventory/cycleCountDetail/service/CycleCountDetailService.java
index b2df118..8087e81 100644
--- a/src/main/java/com/huaheng/pc/inventory/cycleCountDetail/service/CycleCountDetailService.java
+++ b/src/main/java/com/huaheng/pc/inventory/cycleCountDetail/service/CycleCountDetailService.java
@@ -3,8 +3,10 @@ package com.huaheng.pc.inventory.cycleCountDetail.service;
 import com.baomidou.mybatisplus.extension.service.IService;
 import com.huaheng.framework.web.domain.AjaxResult;
 import com.huaheng.pc.inventory.cycleCountDetail.domain.CycleCountDetail;
+import org.apache.poi.ss.formula.functions.T;
 
 import java.math.BigDecimal;
+import java.util.List;
 
 
 public interface CycleCountDetailService extends IService<CycleCountDetail> {
@@ -14,7 +16,7 @@ public interface CycleCountDetailService extends IService<CycleCountDetail> {
 
     AjaxResult createCycleCountTaskByHeadId(String cycleCountHeadCode);
 
-    AjaxResult createCycleCoutTaskByDetailId(Integer cycleCoutdetailId);
+    AjaxResult createCycleCoutTaskByDetailId(Integer cycleCoutDetailId);
 
     AjaxResult confirmGapQty(Integer detailId, BigDecimal qty);
 
@@ -22,7 +24,7 @@ public interface CycleCountDetailService extends IService<CycleCountDetail> {
 
     AjaxResult createCyclecountWithGapQty(String cycleCountHeadCode);
 
-
+    List<CycleCountDetail> preferenceRealize (List<CycleCountDetail> cycleCoutDetailList);
 
 }
 
diff --git a/src/main/java/com/huaheng/pc/inventory/cycleCountDetail/service/CycleCountDetailServiceImpl.java b/src/main/java/com/huaheng/pc/inventory/cycleCountDetail/service/CycleCountDetailServiceImpl.java
index c7a6538..2b52eda 100644
--- a/src/main/java/com/huaheng/pc/inventory/cycleCountDetail/service/CycleCountDetailServiceImpl.java
+++ b/src/main/java/com/huaheng/pc/inventory/cycleCountDetail/service/CycleCountDetailServiceImpl.java
@@ -7,6 +7,10 @@ import com.huaheng.common.exception.service.ServiceException;
 import com.huaheng.common.utils.StringUtils;
 import com.huaheng.common.utils.security.ShiroUtils;
 import com.huaheng.framework.web.domain.AjaxResult;
+import com.huaheng.pc.config.configValue.domain.ConfigValue;
+import com.huaheng.pc.config.configValue.service.ConfigValueService;
+import com.huaheng.pc.config.cycleCountPreference.domain.CycleCountPreference;
+import com.huaheng.pc.config.cycleCountPreference.service.CycleCountPreferenceService;
 import com.huaheng.pc.config.location.domain.Location;
 import com.huaheng.pc.config.location.service.LocationService;
 import com.huaheng.pc.inventory.cycleCountDetail.domain.CycleCountDetail;
@@ -43,9 +47,10 @@ public class CycleCountDetailServiceImpl extends ServiceImpl<CycleCountDetailMap
     private TaskHeaderService taskHeaderService;
     @Resource
     private TaskDetailService taskDetailService;
-
-
-
+    @Resource
+    private ConfigValueService configValueService;
+    @Resource
+    private CycleCountPreferenceService cycleCountPreferenceService;
 
 
     /**
@@ -101,6 +106,16 @@ public class CycleCountDetailServiceImpl extends ServiceImpl<CycleCountDetailMap
         if(cyclecountHeader.getStatusCyc() > 1){
             return AjaxResult.error("盘点单非新建状态,无法再添加明细");
         }
+        //默认盘点配置,首选项
+        ConfigValue configValue = new ConfigValue();
+        configValue.setModuleType("cyclecount");
+        configValue.setWarehouseCode(ShiroUtils.getWarehouseCode());
+        LambdaQueryWrapper<ConfigValue> configValueLambdaQueryWrapper = Wrappers.lambdaQuery(configValue);
+        configValue = configValueService.getOne(configValueLambdaQueryWrapper);
+        if(configValue == null){
+            throw new SecurityException("请先在配置中添加盘点配置");
+        }
+        String preferenceCode = configValue.getIdentifier();
         //获取已经存在的明细
         CycleCountDetail cycleCountDetail = new CycleCountDetail();
         cycleCountDetail.setWarehouseCode(cyclecountHeader.getWarehouseCode());
@@ -118,9 +133,9 @@ public class CycleCountDetailServiceImpl extends ServiceImpl<CycleCountDetailMap
             }
             //查询该条库存明细
             InventoryDetail inventoryDetail = inventoryDetailService.getById(inventoryDetailId);
-
             //写入盘点明细
             CycleCountDetail ccd = new CycleCountDetail();
+            ccd.setPreferenceCode(preferenceCode);
             ccd.setCycleCountHeadCode(cyclecountHeader.getCode());
             ccd.setInventoryDetailId(inventoryDetailId);
             ccd.setWarehouseCode(inventoryDetail.getWarehouseCode());
@@ -189,7 +204,7 @@ public class CycleCountDetailServiceImpl extends ServiceImpl<CycleCountDetailMap
                 }
             }
         }
-        String msg = "";
+        String msg = null;
         if(count==list.size()){
             msg="全部生成成功";
         } else if (count <= 0 && countErr <= 0){
@@ -202,17 +217,17 @@ public class CycleCountDetailServiceImpl extends ServiceImpl<CycleCountDetailMap
 
     /**
      * 生成单条盘点任务
-     * @param cycleCoutdetailId
+     * @param cycleCoutDetailId
      * @return
      */
     @Override
     @Transactional
-    public AjaxResult createCycleCoutTaskByDetailId(Integer cycleCoutdetailId) {
+    public AjaxResult createCycleCoutTaskByDetailId(Integer cycleCoutDetailId) {
         /*任务主表中存在库位,在盘点明细中生成任务时,不同的容器生成不同的主任务*/
         //在盘点单生成任务并执行后,同一容器的物料仍然可以生成任务,否则任务已完成则无法添加任务100
         //检查状态不为100的任务,在有和下发的盘点单容器相同的任务时,把该条明细的任务写入到当前相同容器的任务里
 
-        CycleCountDetail cycleCountDetail = this.getById(cycleCoutdetailId);
+        CycleCountDetail cycleCountDetail = this.getById(cycleCoutDetailId);
         if(cycleCountDetail == null ){
             return AjaxResult.error("盘点明细ID错误,没有该条明细");
         }
@@ -456,11 +471,65 @@ public class CycleCountDetailServiceImpl extends ServiceImpl<CycleCountDetailMap
         return AjaxResult.success("生成复盘单成功!");
     }
 
+    /**
+     * 盘点首选项实现
+     * @param cycleCoutDetailList
+     * @return
+     */
+    @Transactional
+    @Override
+    public List<CycleCountDetail> preferenceRealize(List<CycleCountDetail> cycleCoutDetailList) {
+        List<CycleCountDetail> cycs = new ArrayList<>();
+        /*
+        根据当前明细条目的盘点首选Code,取出显示要求,再根据显示要求隐藏或显示字段*/
+        /*//配置表
+        ConfigValue configValue = new ConfigValue();
+        configValue.setModuleType("cyclecount");
+        configValue.setWarehouseCode(ShiroUtils.getWarehouseCode());
+        LambdaQueryWrapper<ConfigValue> configValueLambdaQueryWrapper = Wrappers.lambdaQuery(configValue);
+        ConfigValue value = configValueService.getOne(configValueLambdaQueryWrapper);
+        if(value == null){
+            throw new SecurityException("请先在配置中添加盘点配置");
+        }*/
 
+        //取出preference的数据来判断字段
+        for(CycleCountDetail item:cycleCoutDetailList){
+            //盘点首选项
+            CycleCountPreference temp = new CycleCountPreference();
+            temp.setCode(item.getPreferenceCode());
+            temp.setWarehouseCode(item.getWarehouseCode());
+            LambdaQueryWrapper<CycleCountPreference> cycleCountPreferenceLambdaQuery = Wrappers.lambdaQuery(temp);
+            CycleCountPreference cycleCountPreference = cycleCountPreferenceService.getOne(cycleCountPreferenceLambdaQuery);
+            if(cycleCountPreference == null){
+                throw new SecurityException("没有对应的盘点首选项!");
+            }
+            if(cycleCountPreference.getEnable() == false){
+                throw new SecurityException("当前默认选中盘点首选项已停用!");
+            }
+            //判断字段
+            if(cycleCountPreference.getPromptLocation() == false){
+                //库位
+                item.setLocationCode("");
+            }
+            if(cycleCountPreference.getPromptLpn() == false){
+                //容器
+                item.setContainerCode("");
+            }
+            if(cycleCountPreference.getPromptItem() == false){
+                //物料
+                item.setMaterialCode("");
+                item.setMaterialName("");
+                item.setMaterialUnit("");
+            }
+            if(cycleCountPreference.getPromptQuantity() == false){
+                //系统数量
+                item.setSystemQty(null);
+            }
+            cycs.add(item);
+        }
 
-
-
-
+        return cycs;
+    }
 
 
 }
diff --git a/src/main/resources/mybatis/config/LocationMapper.xml b/src/main/resources/mybatis/config/LocationMapper.xml
index 00802a4..87c959e 100644
--- a/src/main/resources/mybatis/config/LocationMapper.xml
+++ b/src/main/resources/mybatis/config/LocationMapper.xml
@@ -13,6 +13,7 @@
     <result column="iColumn" jdbcType="INTEGER" property="iColumn" />
     <result column="iLayer" jdbcType="INTEGER" property="iLayer" />
     <result column="iGrid" jdbcType="INTEGER" property="iGrid" />
+    <result column="roadway" jdbcType="VARCHAR" property="roadway" />
     <result column="name" jdbcType="VARCHAR" property="name" />
     <result column="lastCycleCountDate" jdbcType="TIMESTAMP" property="lastCycleCountDate" />
     <result column="created" jdbcType="TIMESTAMP" property="created" />
@@ -33,7 +34,7 @@
   <sql id="Base_Column_List">
     <!--@mbg.generated-->
     id, code, warehouseCode, zoneCode, locationType, containerCode, iRow, iColumn, iLayer, 
-    iGrid, `name`, `enable`, lastCycleCountDate, created, createdBy, lastUpdated, lastUpdatedBy, 
+    iGrid, roadway, `name`, `enable`, lastCycleCountDate, created, createdBy, lastUpdated, lastUpdatedBy,
     version, userDef1, userDef2, userDef3, userDef4, userDef5, userDef6, userDef7, userDef8, 
     systemCreated
   </sql>
diff --git a/src/main/resources/templates/config/configValue/configValue.html b/src/main/resources/templates/config/configValue/configValue.html
index c3ca7f7..dd36581 100644
--- a/src/main/resources/templates/config/configValue/configValue.html
+++ b/src/main/resources/templates/config/configValue/configValue.html
@@ -48,6 +48,8 @@
     var prefix = ctx + "config/configValue";
     var editFlag = [[${@permission.hasPermi('config:configValue:edit')}]];
     var removeFlag = [[${@permission.hasPermi('config:configValue:remove')}]];
+    var recordType=[[${@dict.getType('recordType')}]];
+
     $(function() {
         var options = {
             url: prefix + "/list",
@@ -74,8 +76,12 @@
                     title : '模块'
                 },
                 {
-                    field : 'recordType',
-                    title : '类型'
+                    field: 'recordType',
+                    title: '类型',
+                    formatter: function(value, row, index) {
+                        return $.table.selectDictLabel(recordType, value);
+                    },
+
                 },
                 {
                     field : 'identifier',
diff --git a/src/main/resources/templates/config/cycleCountPreference/edit.html b/src/main/resources/templates/config/cycleCountPreference/edit.html
index 133a877..c22b605 100644
--- a/src/main/resources/templates/config/cycleCountPreference/edit.html
+++ b/src/main/resources/templates/config/cycleCountPreference/edit.html
@@ -164,13 +164,14 @@
             promptQuantity: {
                 required: true,
             },
-            allowAddNewInventory: {
-                required: true,
-            }
         },
         submitHandler: function(form) {
             var tableValue = $.common.getTableValue("#form-cycleCountPreference-edit");
-            /*tableValue = formValueReplace(tableValue, "id", $("input[name='id']").is(':checked'));*/
+            tableValue = formValueReplace(tableValue, "promptLocation", $("input[name='promptLocation']").is(':checked'));
+            tableValue = formValueReplace(tableValue, "promptLpn", $("input[name='promptLpn']").is(':checked'));
+            tableValue = formValueReplace(tableValue, "promptItem", $("input[name='promptItem']").is(':checked'));
+            tableValue = formValueReplace(tableValue, "promptQuantity", $("input[name='promptQuantity']").is(':checked'));
+            tableValue = formValueReplace(tableValue, "enable", $("input[name='enable']").is(':checked'));
             $.operate.save(prefix + "/edit", tableValue);
         }
     });
diff --git a/src/main/resources/templates/config/location/addBatch.html b/src/main/resources/templates/config/location/addBatch.html
index 972b851..cb097aa 100644
--- a/src/main/resources/templates/config/location/addBatch.html
+++ b/src/main/resources/templates/config/location/addBatch.html
@@ -30,6 +30,12 @@
 				</div>
 			</div>
 			<div class="form-group">
+				<label class="col-sm-3 control-label">巷道:</label>
+				<div class="col-sm-8">
+					<input id="roadway" name="roadway" class="form-control" type="text">
+				</div>
+			</div>
+			<div class="form-group">
 				<label class="col-sm-3 control-label">库位类型:</label>
 				<div class="col-sm-8">
 					<select id="locationType" name="locationType" class="form-control" th:with="locationType=${@locationType.getLocationPrefix()}">
@@ -104,6 +110,7 @@
                         "iColumn": $("input[name='iColumn']").val(),
                         "iLayer": $("input[name='iLayer']").val(),
                         "iGrid": $("input[name='iGrid']").val(),
+						"roadway": $("input[name='roadway']").val(),
                         "locationType": $("#locationType option:selected").val(),
                         "zoneCode": $("#zone option:selected").attr("code"),
                         "status" : $("#status option:selected").val(),
diff --git a/src/main/resources/templates/config/location/location.html b/src/main/resources/templates/config/location/location.html
index 7582f1c..06d13b5 100644
--- a/src/main/resources/templates/config/location/location.html
+++ b/src/main/resources/templates/config/location/location.html
@@ -68,7 +68,7 @@
 			<a class="btn btn-outline btn-success btn-rounded" onclick="$.operate.add()" shiro:hasPermission="config:location:add">
 				<i class="fa fa-plus"></i> 新增
 			</a>
-			<a class="btn btn-outline btn-primary btn-rounded" onclick="addBatch()" shiro:hasPermission="config:location:add">
+			<a class="btn btn-outline btn-primary btn-rounded" onclick="addBatch()" shiro:hasPermission="config:location:addBatch">
 				<i class="fa fa-plus-square-o"></i> 批量新增
 			</a>
 			<a class="btn btn-outline btn-danger btn-rounded" onclick="$.operate.batRemove()" shiro:hasPermission="config:location:remove">
@@ -133,6 +133,10 @@
                     title : '格'
                 },
 				{
+					field : 'roadway',
+					title : '巷道'
+				},
+				{
 					field : 'name',
 					title : '名称',
 					visible : false
diff --git a/src/main/resources/templates/inventory/cycleCountDetail/cycleCountDetail.html b/src/main/resources/templates/inventory/cycleCountDetail/cycleCountDetail.html
index 430338b..318e153 100644
--- a/src/main/resources/templates/inventory/cycleCountDetail/cycleCountDetail.html
+++ b/src/main/resources/templates/inventory/cycleCountDetail/cycleCountDetail.html
@@ -155,6 +155,10 @@
                     title: '仓库',
                 },
                 {
+                    field: 'preferenceCode',
+                    title: '盘点首选项编码',
+                },
+                {
                     field: 'countId',
                     title: '盘点内部号',
                     visible: false