diff --git a/api-admin/src/main/java/com/glxp/sale/admin/controller/thrsys/ThrInvWarehouseController.java b/api-admin/src/main/java/com/glxp/sale/admin/controller/thrsys/ThrInvWarehouseController.java
index d2b6ca7..e5ceaba 100644
--- a/api-admin/src/main/java/com/glxp/sale/admin/controller/thrsys/ThrInvWarehouseController.java
+++ b/api-admin/src/main/java/com/glxp/sale/admin/controller/thrsys/ThrInvWarehouseController.java
@@ -71,13 +71,33 @@ public class ThrInvWarehouseController {
             return ResultVOUtils.error(ResultEnum.PARAM_VERIFY_FALL, bindingResult.getFieldError().getDefaultMessage());
         }
 
-        if (thrInvWarehouseEntity.getPid() == null) {
+        if (thrInvWarehouseEntity.getPid() == null) {//仓库
             thrInvWarehouseEntity.setPid(0); // 默认设置
+            FilterThrInvWarehouseRequest filterThrInvWarehouseRequest = new FilterThrInvWarehouseRequest();
+            filterThrInvWarehouseRequest.setPid(thrInvWarehouseEntity.getPid());
+            ThrInvWarehouseEntity codeEntity = thrInvWarehouseService.selectMaxCode(filterThrInvWarehouseRequest);
+            thrInvWarehouseEntity.setCode(Integer.parseInt(codeEntity.getCode()) + 1 + "");
+        } else {//货位
+
+            FilterThrInvWarehouseRequest filterThrInvWarehouseRequest = new FilterThrInvWarehouseRequest();
+            filterThrInvWarehouseRequest.setPid(thrInvWarehouseEntity.getPid());
+            ThrInvWarehouseEntity codeEntity = thrInvWarehouseService.selectMaxCode(filterThrInvWarehouseRequest);
+            ThrInvWarehouseEntity pEntity = thrInvWarehouseService.selectById(thrInvWarehouseEntity.getPid() + "");
+            if (codeEntity == null) {
+                int code = Integer.parseInt(pEntity.getCode()) * 1000;
+                thrInvWarehouseEntity.setCode(code + "");
+            } else {
+                thrInvWarehouseEntity.setCode(Integer.parseInt(codeEntity.getCode()) + 1 + "");
+            }
+            thrInvWarehouseEntity.setAdvanceType(pEntity.getAdvanceType());
+            thrInvWarehouseEntity.setLevel(pEntity.getLevel());
+            thrInvWarehouseEntity.setPcode(pEntity.getPcode());
         }
         boolean b = thrInvWarehouseService.insertInvWarehouse(thrInvWarehouseEntity);
         if (!b) {
             return ResultVOUtils.error(ResultEnum.NOT_NETWORK);
         }
+
         return ResultVOUtils.success("添加成功!");
     }
 
diff --git a/api-admin/src/main/java/com/glxp/sale/admin/dao/thrsys/ThrInvWarehouseDao.java b/api-admin/src/main/java/com/glxp/sale/admin/dao/thrsys/ThrInvWarehouseDao.java
index 5124861..175689c 100644
--- a/api-admin/src/main/java/com/glxp/sale/admin/dao/thrsys/ThrInvWarehouseDao.java
+++ b/api-admin/src/main/java/com/glxp/sale/admin/dao/thrsys/ThrInvWarehouseDao.java
@@ -27,4 +27,6 @@ public interface ThrInvWarehouseDao {
      * @return
      */
     ThrInvWarehouseEntity selectByCode(@Param("code") String code);
+
+    ThrInvWarehouseEntity selectMaxCode(FilterThrInvWarehouseRequest filterThrInvWarehouseRequest);
 }
diff --git a/api-admin/src/main/java/com/glxp/sale/admin/req/thrsys/FilterThrInvWarehouseRequest.java b/api-admin/src/main/java/com/glxp/sale/admin/req/thrsys/FilterThrInvWarehouseRequest.java
index 8833fc1..39ad120 100644
--- a/api-admin/src/main/java/com/glxp/sale/admin/req/thrsys/FilterThrInvWarehouseRequest.java
+++ b/api-admin/src/main/java/com/glxp/sale/admin/req/thrsys/FilterThrInvWarehouseRequest.java
@@ -16,4 +16,6 @@ public class FilterThrInvWarehouseRequest extends ListPageRequest {
     private Boolean isDefault;
     private Date updateTime;
     private String key;
+    private String pcode;
+    private Integer level;
 }
diff --git a/api-admin/src/main/java/com/glxp/sale/admin/service/thrsys/ThrInvWarehouseService.java b/api-admin/src/main/java/com/glxp/sale/admin/service/thrsys/ThrInvWarehouseService.java
index 5b905f9..1f8b2df 100644
--- a/api-admin/src/main/java/com/glxp/sale/admin/service/thrsys/ThrInvWarehouseService.java
+++ b/api-admin/src/main/java/com/glxp/sale/admin/service/thrsys/ThrInvWarehouseService.java
@@ -25,4 +25,5 @@ public interface ThrInvWarehouseService {
 
     boolean deleteById(String id);
 
+    ThrInvWarehouseEntity selectMaxCode(FilterThrInvWarehouseRequest filterThrInvWarehouseRequest);
 }
diff --git a/api-admin/src/main/java/com/glxp/sale/admin/service/thrsys/impl/ThrInvWarehouseServiceImpl.java b/api-admin/src/main/java/com/glxp/sale/admin/service/thrsys/impl/ThrInvWarehouseServiceImpl.java
index a85eae1..4c417b9 100644
--- a/api-admin/src/main/java/com/glxp/sale/admin/service/thrsys/impl/ThrInvWarehouseServiceImpl.java
+++ b/api-admin/src/main/java/com/glxp/sale/admin/service/thrsys/impl/ThrInvWarehouseServiceImpl.java
@@ -83,4 +83,9 @@ public class ThrInvWarehouseServiceImpl implements ThrInvWarehouseService {
     public boolean deleteById(String id) {
         return thrInvWarehouseDao.deleteById(id);
     }
+
+    @Override
+    public ThrInvWarehouseEntity selectMaxCode(FilterThrInvWarehouseRequest filterThrInvWarehouseRequest) {
+        return thrInvWarehouseDao.selectMaxCode(filterThrInvWarehouseRequest);
+    }
 }
diff --git a/api-admin/src/main/resources/mybatis/mapper/thrsys/ThrInvWarehouseDao.xml b/api-admin/src/main/resources/mybatis/mapper/thrsys/ThrInvWarehouseDao.xml
index e269047..7ff6c38 100644
--- a/api-admin/src/main/resources/mybatis/mapper/thrsys/ThrInvWarehouseDao.xml
+++ b/api-admin/src/main/resources/mybatis/mapper/thrsys/ThrInvWarehouseDao.xml
@@ -100,4 +100,34 @@
     <select id="selectByCode" resultType="com.glxp.sale.admin.entity.thrsys.ThrInvWarehouseEntity">
         select * from thr_inv_warehouse where code = #{code}
     </select>
+
+    <select id="selectMaxCode" resultType="com.glxp.sale.admin.entity.thrsys.ThrInvWarehouseEntity">
+        select max(code) as code from thr_inv_warehouse
+        <where>
+            <if test="id != '' and id != null">
+                AND id = #{id}
+            </if>
+            <if test="pid != '' and pid != null">
+                AND pid = #{pid}
+            </if>
+            <if test="code != '' and code != null">
+                AND code = #{code}
+            </if>
+            <if test="name != '' and name != null">
+                AND name = #{name}
+            </if>
+            <if test=" advanceType != null">
+                AND advanceType = #{advanceType}
+            </if>
+            <if test="isDefault != null">
+                AND isDefault = #{isDefault}
+            </if>
+            <if test="pcode != null">
+                AND pcode = #{pcode}
+            </if>
+            <if test="level != null">
+                AND level = #{level}
+            </if>
+        </where>
+    </select>
 </mapper>
\ No newline at end of file