Kaynağa Gözat

BI大屏接口外部用户权限优化

Sun 3 yıl önce
ebeveyn
işleme
d97bc8ee34

+ 8 - 8
ruoyi-admin/src/main/java/com/ruoyi/web/controller/warehouse/reportManagement/TWarehousebillsitemsSummaryController.java

@@ -129,16 +129,16 @@ public class TWarehousebillsitemsSummaryController extends BaseController {
      * bi大屏客户数量
      */
     @GetMapping("/biCustomerCount")
-    public AjaxResult biCustomerCount(Long warehouseId) {
-        return AjaxResult.success(itCorpsService.biCustomerCount(warehouseId));
+    public AjaxResult biCustomerCount(Long warehouseId, Long customerId) {
+        return AjaxResult.success(itCorpsService.biCustomerCount(warehouseId, customerId));
     }
 
     /**
      * bi大屏客户概况
      */
     @GetMapping("/biCustomerInfo")
-    public AjaxResult biCustomerInfo(Long warehouseId) {
-        return AjaxResult.success(itWhgenlegService.biCustomerInfo(warehouseId));
+    public AjaxResult biCustomerInfo(Long warehouseId, Long customerId) {
+        return AjaxResult.success(itWhgenlegService.biCustomerInfo(warehouseId, customerId));
     }
 
     /**
@@ -169,8 +169,8 @@ public class TWarehousebillsitemsSummaryController extends BaseController {
      * bi大屏协议数量
      */
     @GetMapping("/biContractCount")
-    public AjaxResult biContractCount() {
-        return AjaxResult.success(itWarehouseAgreementService.biContractCount());
+    public AjaxResult biContractCount(Long customerId) {
+        return AjaxResult.success(itWarehouseAgreementService.biContractCount(customerId));
     }
 
     /**
@@ -219,9 +219,9 @@ public class TWarehousebillsitemsSummaryController extends BaseController {
      * bi大屏仓储协议列表
      */
     @GetMapping("/biContractList")
-    public TableDataInfo biContractList() {
+    public TableDataInfo biContractList(Long customerId) {
         startPage();
-        return getDataTable(itWarehouseAgreementService.biContractList());
+        return getDataTable(itWarehouseAgreementService.biContractList(customerId));
     }
 
 }

+ 3 - 1
ruoyi-warehouse/src/main/java/com/ruoyi/basicData/mapper/TCorpsMapper.java

@@ -160,7 +160,9 @@ public interface TCorpsMapper extends BaseMapper<TCorps> {
      *
      * @return
      */
-    public Map<String, Object> biCustomerCount(Long warehouseId);
+    public Map<String, Object> biCustomerCount(@Param("external") String external,
+                                               @Param("warehouseId") Long warehouseId,
+                                               @Param("customerId") Long customerId);
 
     /**
      * bi大屏客户列表

+ 1 - 1
ruoyi-warehouse/src/main/java/com/ruoyi/basicData/service/ITCorpsService.java

@@ -119,7 +119,7 @@ public interface ITCorpsService {
      *
      * @return
      */
-    public Map<String, Object> biCustomerCount(Long warehouseId);
+    public Map<String, Object> biCustomerCount(Long warehouseId, Long customerId);
 
     /**
      * bi大屏客户列表

+ 8 - 2
ruoyi-warehouse/src/main/java/com/ruoyi/basicData/service/impl/TCorpsServiceImpl.java

@@ -383,8 +383,14 @@ public class TCorpsServiceImpl implements ITCorpsService {
      * @return
      */
     @Override
-    public Map<String, Object> biCustomerCount(Long warehouseId) {
-        return tCorpsMapper.biCustomerCount(warehouseId);
+    public Map<String, Object> biCustomerCount(Long warehouseId, Long customerId) {
+        String external = null;
+        SysUser user = SecurityUtils.getLoginUser().getUser();
+        if ("外部用户".equals(user.getDept().getDeptName())) {
+            external = user.getUserName();
+        }
+
+        return tCorpsMapper.biCustomerCount(external, warehouseId, customerId);
     }
 
     /**

+ 3 - 10
ruoyi-warehouse/src/main/java/com/ruoyi/reportManagement/mapper/TWhgenlegMapper.java

@@ -202,15 +202,8 @@ public interface TWhgenlegMapper {
      *
      * @return
      */
-    public List<Map<String, Object>> biCustomerInfo(Long warehouseId);
-
-    /**
-     * bi大屏毛重概况
-     *
-     * @return
-     */
-    public Map<String, Object> biWeightInfo(@Param("beginDate") String beginDate,
-                                                  @Param("endDate") String endDate,
-                                                  @Param("warehouseId") Long warehouseId);
+    public List<Map<String, Object>> biCustomerInfo(@Param("external") String external,
+                                                    @Param("warehouseId") Long warehouseId,
+                                                    @Param("customerId") Long customerId);
 
 }

+ 1 - 1
ruoyi-warehouse/src/main/java/com/ruoyi/reportManagement/service/ITWhgenlegService.java

@@ -178,7 +178,7 @@ public interface ITWhgenlegService {
      *
      * @return
      */
-    public List<Map<String, Object>> biCustomerInfo(Long warehouseId);
+    public List<Map<String, Object>> biCustomerInfo(Long warehouseId, Long customerId);
 
     /**
      * bi库存数量

+ 8 - 2
ruoyi-warehouse/src/main/java/com/ruoyi/reportManagement/service/impl/TWhgenlegServiceImpl.java

@@ -647,8 +647,14 @@ public class TWhgenlegServiceImpl implements ITWhgenlegService {
      * @return
      */
     @Override
-    public List<Map<String, Object>> biCustomerInfo(Long warehouseId) {
-        return tWhgenlegMapper.biCustomerInfo(warehouseId);
+    public List<Map<String, Object>> biCustomerInfo(Long warehouseId, Long customerId) {
+        String external = null;
+        SysUser user = SecurityUtils.getLoginUser().getUser();
+        if ("外部用户".equals(user.getDept().getDeptName())) {
+            external = user.getUserName();
+        }
+
+        return tWhgenlegMapper.biCustomerInfo(external, warehouseId, customerId);
     }
 
     /**

+ 6 - 2
ruoyi-warehouse/src/main/java/com/ruoyi/warehouseBusiness/mapper/TWarehouseAgreementMapper.java

@@ -84,13 +84,17 @@ public interface TWarehouseAgreementMapper {
      *
      * @return
      */
-    public Map<String, Object> biContractCount(@Param("beginDate") String beginDate, @Param("endDate") String endDate);
+    public Map<String, Object> biContractCount(@Param("beginDate") String beginDate,
+                                               @Param("endDate") String endDate,
+                                               @Param("external") String external,
+                                               @Param("customerId") Long customerId);
 
     /**
      * 仓储协议列表
      *
      * @return 仓储费集合
      */
-    public List<Map<String, Object>> biContractList();
+    public List<Map<String, Object>> biContractList(@Param("external") String external,
+                                                    @Param("customerId") Long customerId);
 
 }

+ 2 - 2
ruoyi-warehouse/src/main/java/com/ruoyi/warehouseBusiness/service/ITWarehouseAgreementService.java

@@ -85,13 +85,13 @@ public interface ITWarehouseAgreementService {
      *
      * @return
      */
-    public Map<String, Object> biContractCount();
+    public Map<String, Object> biContractCount(Long customerId);
 
     /**
      * 仓储协议列表
      *
      * @return 仓储费集合
      */
-    public List<Map<String, Object>> biContractList();
+    public List<Map<String, Object>> biContractList(Long customerId);
 
 }

+ 18 - 4
ruoyi-warehouse/src/main/java/com/ruoyi/warehouseBusiness/service/impl/TWarehouseAgreementServiceImpl.java

@@ -11,10 +11,12 @@ import com.ruoyi.basicData.domain.TFees;
 import com.ruoyi.basicData.mapper.TCorpsMapper;
 import com.ruoyi.basicData.mapper.TFeesMapper;
 import com.ruoyi.common.core.domain.AjaxResult;
+import com.ruoyi.common.core.domain.entity.SysUser;
 import com.ruoyi.common.core.domain.model.LoginUser;
 import com.ruoyi.common.exception.BaseException;
 import com.ruoyi.common.exception.WarehouseException;
 import com.ruoyi.common.utils.DateUtils;
+import com.ruoyi.common.utils.SecurityUtils;
 import com.ruoyi.common.utils.StringUtils;
 import com.ruoyi.system.domain.SysConfig;
 import com.ruoyi.system.mapper.SysConfigMapper;
@@ -699,11 +701,17 @@ public class TWarehouseAgreementServiceImpl implements ITWarehouseAgreementServi
      * @return
      */
     @Override
-    public Map<String, Object> biContractCount() {
+    public Map<String, Object> biContractCount(Long customerId) {
         String beginDate = DateUtils.today() + " 00:00:00";
         String endDate = DateUtils.offsetMonth(2) + " 23:59:59";
 
-        return tWarehouseAgreementMapper.biContractCount(beginDate, endDate);
+        String external = null;
+        SysUser user = SecurityUtils.getLoginUser().getUser();
+        if ("外部用户".equals(user.getDept().getDeptName())) {
+            external = user.getUserName();
+        }
+
+        return tWarehouseAgreementMapper.biContractCount(beginDate, endDate, external, customerId);
     }
 
     /**
@@ -712,8 +720,14 @@ public class TWarehouseAgreementServiceImpl implements ITWarehouseAgreementServi
      * @return 仓储费集合
      */
     @Override
-    public List<Map<String, Object>> biContractList() {
-        return tWarehouseAgreementMapper.biContractList();
+    public List<Map<String, Object>> biContractList(Long customerId) {
+        String external = null;
+        SysUser user = SecurityUtils.getLoginUser().getUser();
+        if ("外部用户".equals(user.getDept().getDeptName())) {
+            external = user.getUserName();
+        }
+
+        return tWarehouseAgreementMapper.biContractList(external, customerId);
     }
 
 }

+ 8 - 5
ruoyi-warehouse/src/main/resources/mapper/basicData/TCorpsMapper.xml

@@ -458,13 +458,16 @@
             </foreach>
     </select>
 
-    <select id="biCustomerCount" parameterType="long" resultType="map">
+    <select id="biCustomerCount" resultType="map">
         select count(f_id) as customerCount
         from t_corps
-        where f_id in (
-            select distinct f_corpid from t_whgenleg where f_qtyD != 0 and f_qtyblc != 0
-                <if test="warehouseId != null"> and f_warehouseid = #{warehouseId}</if>
-        );
+        where
+            f_id in (
+                select distinct f_corpid from t_whgenleg where f_qtyD != 0 and f_qtyblc != 0
+                    <if test="warehouseId != null">and f_warehouseid = #{warehouseId}</if>
+                    <if test="external != null">and f_corpid = (select f_pid from t_customer_contact where f_tel = #{external})</if>
+                    <if test="customerId != null">and f_corpid = #{customerId}</if>
+            )
     </select>
 
     <select id="biCustomerList" resultType="map">

+ 7 - 16
ruoyi-warehouse/src/main/resources/mapper/reportManagement/TWhgenlegMapper.xml

@@ -1247,28 +1247,19 @@
 
     <select id="biCustomerInfo" resultType="map">
         select
-            tc.f_cname as customerName,
+            ifnull(ifnull(tw.f_shipper, tc.f_cname), tc.f_name) as customerName,
             round(ifnull(sum(tw.f_grossweightblc), 0) / 1000) as quantity
         from t_whgenleg tw left join t_corps tc on tw.f_corpid = tc.f_id
         where
             tw.f_qtyD != 0
             and tw.f_qtyblc != 0
-            <if test="warehouseId != null"> and f_warehouseid = #{warehouseId}</if>
-        group by tc.f_name
+            <if test="warehouseId != null"> and tw.f_warehouseid = #{warehouseId}</if>
+            <if test="external != null and external != ''">
+                and tw.f_corpid = (select f_pid from t_customer_contact where f_tel = #{external})
+            </if>
+            <if test="customerId != null"> and tw.f_corpid = #{customerId}</if>
+        group by customerName
         order by quantity desc limit 10
     </select>
 
-    <select id="biWeightInfo" resultType="map">
-        select
-            round(ifnull(sum(f_grossweightD), 0) / 1000, 2) as quantityIn,
-            round(ifnull(sum(f_grossweightblc), 0) / 1000, 2) as quantity
-        from t_whgenleg
-        where
-            f_qtyD != 0
-            and f_qtyblc != 0
-            <if test="warehouseId != null and warehouseId != ''">and f_warehouseid = #{warehouseId}</if>
-            <if test="beginDate != null and beginDate != ''">and f_bsdate &gt;= #{beginDate}</if>
-            <if test="endDate != null and endDate != ''">and f_bsdate &lt;= #{endDate}</if>
-    </select>
-
 </mapper>

+ 10 - 2
ruoyi-warehouse/src/main/resources/mapper/warehouseBusiness/TWarehouseAgreementMapper.xml

@@ -281,15 +281,23 @@
         where f_feetypeid = 0
             <if test="beginDate != null and beginDate != ''">and f_enddate &gt;= #{beginDate}</if>
             <if test="endDate != null and endDate != ''">and f_enddate &lt; #{endDate}</if>
+            <if test="external != null and external != ''">
+                and f_corpid = (select f_pid from t_customer_contact where f_tel = #{external})
+            </if>
+            <if test="customerId != null">and f_corpid = #{customerId}</if>
     </select>
 
     <select id="biContractList" resultType="map">
         select
             ifnull(tc.f_cname, tc.f_name) as customerName,
-            ta.f_begindate AS beginDate,
-            ta.f_enddate AS endDate
+            ta.f_begindate as beginDate,
+            ta.f_enddate as endDate
         from t_warehouse_agreement ta left join t_corps tc on tc.f_id = ta.f_corpid
         where ta.f_feetypeid = 0
+            <if test="external != null and external != ''">
+                and ta.f_corpid = (select f_pid from t_customer_contact where f_tel = #{external})
+            </if>
+            <if test="customerId != null">and ta.f_corpid = #{customerId}</if>
         order by ta.create_time desc
     </select>
 

+ 1 - 1
ruoyi-warehouse/src/main/resources/mapper/warehouseBusiness/TWarehousebillsitemsMapper.xml

@@ -984,7 +984,7 @@
     <select id="biInAndOutStockList" resultType="map">
         select
             ifnull(tc.f_cname, tc.f_name) as customerName,
-            tb.f_shipper as shipper,
+            ifnull(tb.f_shipper, tc.f_name) as shipper,
             ts.f_warehouse_information as warehouseName,
             tg.f_name as goodsName,
             concat(ts.f_qty, '/',