Selaa lähdekoodia

完善APP仓库列表查询,外部用户仅可查询自己有库存的仓库

Sun 3 vuotta sitten
vanhempi
commit
180b2e41b3

+ 11 - 0
ruoyi-admin/src/main/java/com/ruoyi/web/controller/warehouse/basicData/TWarehouseController.java

@@ -21,6 +21,7 @@ import org.springframework.web.bind.annotation.*;
 
 import java.util.Iterator;
 import java.util.List;
+import java.util.Map;
 
 /**
  * 仓库Controller
@@ -66,6 +67,16 @@ public class TWarehouseController extends BaseController {
     }
 
     /**
+     * 查询仓库列表
+     */
+    @GetMapping("/appList")
+    public TableDataInfo appList() {
+        startPage();
+        List<Map<String, Object>> list = tWarehouseService.appGetWarehouseList();
+        return getDataTable(list);
+    }
+
+    /**
      * 导出仓库列表
      */
     @PreAuthorize("@ss.hasPermi('basicdata:warehouse:export')")

+ 3 - 0
ruoyi-warehouse/src/main/java/com/ruoyi/basicData/mapper/TWarehouseMapper.java

@@ -6,6 +6,7 @@ import org.apache.ibatis.annotations.Param;
 
 import java.math.BigDecimal;
 import java.util.List;
+import java.util.Map;
 
 /**
  * 仓库Mapper接口
@@ -32,6 +33,8 @@ public interface TWarehouseMapper {
 
     public List<TWarehouse> selectTWarehouseLists(TWarehouse tWarehouse);
 
+    public List<Map<String, Object>> appGetWarehouseList(@Param("corpId") Long corpId);
+
     /**
      * 新增仓库
      *

+ 2 - 0
ruoyi-warehouse/src/main/java/com/ruoyi/basicData/service/ITWarehouseService.java

@@ -39,6 +39,8 @@ public interface ITWarehouseService {
 
     public List<TWarehouse> selectTWarehouseLists(TWarehouse tWarehouse);
 
+    public List<Map<String, Object>> appGetWarehouseList();
+
     /**
      * 新增仓库
      *

+ 21 - 0
ruoyi-warehouse/src/main/java/com/ruoyi/basicData/service/impl/TWarehouseServiceImpl.java

@@ -3,13 +3,16 @@ package com.ruoyi.basicData.service.impl;
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
+import com.ruoyi.basicData.domain.TCustomerContact;
 import com.ruoyi.basicData.domain.TWarehouseArea;
+import com.ruoyi.basicData.mapper.TCustomerContactMapper;
 import com.ruoyi.basicData.mapper.TWarehouseAreaMapper;
 import com.ruoyi.basicData.mapper.TWarehouseMapper;
 import com.ruoyi.basicData.service.ITWarehouseService;
 import com.ruoyi.common.constant.UserConstants;
 import com.ruoyi.common.core.domain.AjaxResult;
 import com.ruoyi.common.core.domain.TreeSelect;
+import com.ruoyi.common.core.domain.entity.SysUser;
 import com.ruoyi.common.core.domain.entity.TWarehouse;
 import com.ruoyi.common.core.domain.model.LoginUser;
 import com.ruoyi.common.exception.CustomException;
@@ -53,6 +56,9 @@ public class TWarehouseServiceImpl implements ITWarehouseService {
     @Autowired
     private TWarehouseBillsMapper tWarehouseBillsMapper;
 
+    @Autowired
+    private TCustomerContactMapper customerContactMapper;
+
 
     /**
      * 查询仓库
@@ -107,6 +113,21 @@ public class TWarehouseServiceImpl implements ITWarehouseService {
         return tWarehouseMapper.selectTWarehouseLists(tWarehouse);
     }
 
+    @Override
+    public List<Map<String, Object>> appGetWarehouseList() {
+        TCustomerContact customerContact = new TCustomerContact();
+        SysUser user = SecurityUtils.getLoginUser().getUser();
+        Long corpId = null;
+        if ("外部用户".equals(user.getDept().getDeptName())) {
+            customerContact.setfTel(SecurityUtils.getLoginUser().getUser().getUserName());
+            List<TCustomerContact> tCustomerContacts = customerContactMapper.selectTCustomerContactList(customerContact);
+            if (CollectionUtils.isNotEmpty(tCustomerContacts)) {
+                corpId = tCustomerContacts.get(0).getfPid();
+            }
+        }
+        return tWarehouseMapper.appGetWarehouseList(corpId);
+    }
+
     /**
      * 新增仓库
      *

+ 13 - 1
ruoyi-warehouse/src/main/resources/mapper/basicData/TWarehouseMapper.xml

@@ -105,6 +105,18 @@
         </where>
     </select>
 
+    <select id="appGetWarehouseList" resultType="map">
+        SELECT
+            f_id AS fId,
+            f_name AS fName
+        FROM t_warehouse
+        WHERE parent_id = 100
+        <if test="corpId != null and corpId != ''">
+            AND f_id IN (SELECT DISTINCT f_warehouseid FROM t_whgenleg WHERE f_corpid = #{corpId})
+        </if>
+
+    </select>
+
     <select id="selectTWarehouseById" parameterType="Long" resultMap="TWarehouseResult">
         <include refid="selectTWarehouseVo"/>
         where f_id = #{fId}
@@ -307,4 +319,4 @@
             #{id}
         </foreach>
     </select>
-</mapper>
+</mapper>