zxf 1 ora fa
parent
commit
15e14b2b14

+ 7 - 1
jd-logistics-modules/jd-logistics-system/src/main/java/com/ruoyi/logistics/config/LargeDataScopeAspect.java

@@ -22,7 +22,10 @@ public class LargeDataScopeAspect {
     public static final String DATA_SCOPE_CUSTOM = "2";
     public static final String DATA_SCOPE_DEPT = "3";
     public static final String DATA_SCOPE_DEPT_AND_CHILD = "4";
-
+    /**
+     * 仅本人数据权限
+     */
+    public static final String DATA_SCOPE_SELF = "5";
     /**
      * 大屏专用数据权限切面
      */
@@ -70,6 +73,9 @@ public class LargeDataScopeAspect {
             } else if (DATA_SCOPE_DEPT_AND_CHILD.equals(ds)) {
                 sql.append(" OR ").append(deptAlias).append(".dept_id IN (SELECT dept_id FROM sys_dept WHERE dept_id = ").append(user.getDeptId()).append(" OR find_in_set(").append(user.getDeptId()).append(", ancestors))");
             }
+            else if (DATA_SCOPE_SELF.equals(ds)) {
+                sql.append(" OR ").append(deptAlias).append(".dept_id = ").append(user.getDeptId());
+            }
         }
 
         if (sql.length() > 0) {

+ 4 - 1
jd-logistics-modules/jd-logistics-system/src/main/java/com/ruoyi/logistics/controller/LargeScreenReportController.java

@@ -176,7 +176,10 @@ public class LargeScreenReportController  extends BaseController {
         }
     }
 
-
+    /**
+     * 省份查询轨迹
+     *
+     */
     @PostMapping("/queryLogisticsTrajectory")
     public AjaxResult queryLogisticsTrajectory(@RequestBody LargeRequest largeRequest) {
         try {

+ 5 - 2
jd-logistics-modules/jd-logistics-system/src/main/java/com/ruoyi/logistics/service/impl/LargeScreenReportServiceImpl.java

@@ -90,6 +90,7 @@ public class LargeScreenReportServiceImpl  implements LargeScreenReportService {
     }
 
     @Override
+    @LargeDataScope
     public List<Map> queryOrdersReportByType(LargeRequest largeRequest) {
         if("1".equals(largeRequest.getRankType())){
             return largeScreenReportMapper.queryOrdersReportByFree(largeRequest);
@@ -101,18 +102,19 @@ public class LargeScreenReportServiceImpl  implements LargeScreenReportService {
 
     }
 
+    @LargeDataScope
     @Override
     public Map queryDeptMonthlyGrowthRate(LargeRequest largeRequest) {
 
         Map<String,Object> result=new HashMap<>();
         List<String> month= new ArrayList<>();
         List<BigDecimal> rateAmount= new ArrayList<>();
-        List<BigDecimal> growthRate= new ArrayList<>();
+        List<String> growthRate= new ArrayList<>();
         List<Map<String,Object>> list= largeScreenReportMapper.queryDeptMonthlyGrowthRate(largeRequest);
         for(int i=0;i<list.size();i++){
             month.add(list.get(i).get("month").toString()) ;
             rateAmount.add(new BigDecimal(list.get(i).get("rate_amount").toString()));
-            growthRate.add(new BigDecimal(list.get(i).get("growth_rate").toString()));
+            growthRate.add(list.get(i).get("growth_rate").toString());
         }
         result.put("month",month);
         result.put("rateAmount",rateAmount);
@@ -177,6 +179,7 @@ public class LargeScreenReportServiceImpl  implements LargeScreenReportService {
     }
 
     @Override
+    @LargeDataScope
     public Map queryLogisticsTrajectory(LargeRequest largeRequest) {
         //根据传入的 时间  物流公司 供应商 省份 进行查询 流入和流出省份轨迹
         Map<String,Object> result=new HashMap<>();

+ 77 - 43
jd-logistics-modules/jd-logistics-system/src/main/resources/mapper/logistics/LargeScreenReportMapper.xml

@@ -70,13 +70,13 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         SUM(order_status != 6 AND order_status != 5) AS delivery_num,
         SUM(order_status = 5) AS proper_num
         FROM biz_waybill_order d
-        WHERE d.create_time >=#{startTime} AND d.create_time <![CDATA[<=]]> #{endTime}
+        WHERE DATE_FORMAT(d.create_time, '%Y-%m-%d') >=#{startTime} AND DATE_FORMAT(d.create_time, '%Y-%m-%d') <![CDATA[<=]]> #{endTime}
         <if test="orderType != null and orderType != ''">
             and d.order_type = #{orderType}
         </if>
-      <!--  <if test="deptId != null and deptId != ''">
+        <if test="deptId != null and deptId != ''">
             and d.dept_id = #{deptId}
-        </if>-->
+        </if>
         <!-- 数据范围过滤 -->
         ${params.dataScope}
 
@@ -174,26 +174,27 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             lng,
             lat,count(1) num
         FROM
-            biz_waybill_order a
-                LEFT JOIN sys_city b ON a.receiver_province = b.NAME
+            biz_waybill_order d
+                LEFT JOIN sys_city b ON  d.receiver_province = b.NAME
         WHERE
             b.LEVEL = 0
-       and   a.order_status != 6
+       and    d.order_status != 6
         <if test="orderType != null and orderType != ''">
-            and  a.order_type = #{orderType}
+            and   d.order_type = #{orderType}
         </if>
-        <if test="startDate != null and startDate != ''">
-            and DATE_FORMAT(a.create_time, '%Y-%m-%d') >= #{startDate}
+        <if test="startTime != null and startTime != ''">
+            and DATE_FORMAT( d.create_time, '%Y-%m-%d') >= #{startTime}
         </if>
-        <if test="endDate != null and endDate != ''">
-            and DATE_FORMAT(a.create_time, '%Y-%m-%d')<![CDATA[<=]]>  #{endDate}
+        <if test="endTime != null and endTime != ''">
+            and DATE_FORMAT( d.create_time, '%Y-%m-%d')<![CDATA[<=]]>  #{endTime}
         </if>
         <if test="deptId != null and deptId != ''">
-            and  a.dept_id = #{deptId}
+            and   d.dept_id = #{deptId}
         </if>
         <if test="searchProvince != null and searchProvince != ''">
-            and  a.sender_province = #{searchProvince}
+            and  d.sender_province = #{searchProvince}
         </if>
+        ${params.dataScope}
         group by receiver_province
     </select>
     <!-- 物流轨迹省份查询流入-->
@@ -203,26 +204,27 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             lng,
             lat ,count(1) num
         FROM
-            biz_waybill_order a
-                LEFT JOIN sys_city b ON a.sender_province = b.NAME
+            biz_waybill_order    d
+                LEFT JOIN sys_city b ON d.sender_province = b.NAME
         WHERE
             b.LEVEL = 0
-        and  a.order_status != 6
+        and  d.order_status != 6
         <if test="orderType != null and orderType != ''">
-            and  a.order_type = #{orderType}
+            and  d.order_type = #{orderType}
         </if>
-        <if test="startDate != null and startDate != ''">
-            and DATE_FORMAT(a.create_time, '%Y-%m-%d') >= #{startDate}
+        <if test="startTime != null and startTime != ''">
+            and DATE_FORMAT(d.create_time, '%Y-%m-%d') >= #{startTime}
         </if>
-        <if test="endDate != null and endDate != ''">
-            and DATE_FORMAT(a.create_time, '%Y-%m-%d')<![CDATA[<=]]>  #{endDate}
+        <if test="endTime != null and endTime != ''">
+            and DATE_FORMAT(d.create_time, '%Y-%m-%d')<![CDATA[<=]]>  #{endTime}
         </if>
         <if test="deptId != null and deptId != ''">
-            and  a.dept_id = #{deptId}
+            and  d.dept_id = #{deptId}
         </if>
         <if test="searchProvince != null and searchProvince != ''">
-            and  a.receiver_province = #{searchProvince}
+            and  d.receiver_province = #{searchProvince}
         </if>
+        ${params.dataScope}
         group by sender_province
 
     </select>
@@ -281,11 +283,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         <if test="orderType != null and orderType != ''">
             and  d.order_type = #{orderType}
         </if>
-        <if test="startDate != null and startDate != ''">
-            and DATE_FORMAT(d.create_time, '%Y-%m-%d') >= #{startDate}
+        <if test="startTime != null and startTime != ''">
+            and DATE_FORMAT(d.create_time, '%Y-%m-%d') >= #{startTime}
         </if>
-        <if test="endDate != null and endDate != ''">
-            and DATE_FORMAT(d.create_time, '%Y-%m-%d')<![CDATA[<=]]>  #{endDate}
+        <if test="endTime != null and endTime != ''">
+            and DATE_FORMAT(d.create_time, '%Y-%m-%d')<![CDATA[<=]]>  #{endTime}
         </if>
         <if test="deptId != null and deptId != ''">
             and  d.dept_id = #{deptId}
@@ -371,11 +373,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         <if test="orderType != null and orderType != ''">
             and  order_type = #{orderType}
         </if>
-        <if test="startDate != null and startDate != ''">
-            and DATE_FORMAT(create_time, '%Y-%m-%d') >= #{startDate}
+        <if test="startTime != null and startTime != ''">
+            and DATE_FORMAT(create_time, '%Y-%m-%d') >= #{startTime}
         </if>
-        <if test="endDate != null and endDate != ''">
-            and DATE_FORMAT(create_time, '%Y-%m-%d')<![CDATA[<=]]>  #{endDate}
+        <if test="endTime != null and endTime != ''">
+            and DATE_FORMAT(create_time, '%Y-%m-%d')<![CDATA[<=]]>  #{endTime}
         </if>
         <if test="deptId != null and deptId != ''">
             and  dept_id = #{deptId}
@@ -383,6 +385,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
                          GROUP BY
                              dept_id
                      ) q ON w.dept_id = q.dept_id
+
+                 where w.del_flag='0'
+                   and w.status='0'
                  ORDER BY
                      num DESC
              ) t,
@@ -400,8 +405,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             t1.rate_amount,
             IFNULL(t2.rate_amount, 0) AS last_month_amount,
             CASE
-                WHEN IFNULL(t2.rate_amount, 0) = 0 THEN 0
-                ELSE ROUND((t1.rate_amount - t2.rate_amount) / t2.rate_amount * 100, 2)
+                WHEN IFNULL(t2.rate_amount, 0) = 0 and IFNULL(t1.rate_amount, 0) = 0 then  0
+                WHEN IFNULL(t2.rate_amount, 0) = 0 and IFNULL(t1.rate_amount, 0) !=0 then  100
+                ELSE ROUND((t1.rate_amount - t2.rate_amount) / t2.rate_amount * 100 , 2)
                 END AS growth_rate
         FROM (
                  SELECT
@@ -416,12 +422,27 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
                           LEFT JOIN (
                      SELECT
                          SUM(IFNULL(a.adjust_amount, a.rate_amount)) rate_amount,
-                         DATE_FORMAT(b.create_time, '%Y-%m') AS month
+                         DATE_FORMAT(d.create_time, '%Y-%m') AS month
                      FROM biz_waybill_cost_details a
-                         LEFT JOIN biz_waybill_order b ON a.external_waybill_no = b.external_waybill_no
-                     WHERE b.order_status != 6
-                       AND b.dept_id = #{deptId}
-                     GROUP BY DATE_FORMAT(b.create_time, '%Y-%m')
+                         LEFT JOIN biz_waybill_order d ON a.external_waybill_no = d.external_waybill_no
+                     WHERE d.order_status != 6
+
+
+        <if test="orderType != null and orderType != ''">
+            and  d.order_type = #{orderType}
+        </if>
+        <if test="startDate != null and startDate != ''">
+            and DATE_FORMAT(d.create_time, '%Y-%m-%d') >= #{startDate}
+        </if>
+        <if test="endDate != null and endDate != ''">
+            and DATE_FORMAT(d.create_time, '%Y-%m-%d')<![CDATA[<=]]>  #{endDate}
+        </if>
+        <if test="deptId != null and deptId != ''">
+            AND d.dept_id = #{deptId}
+        </if>
+        <!-- 数据范围过滤 -->
+        ${params.dataScope}
+                     GROUP BY DATE_FORMAT(d.create_time, '%Y-%m')
                  ) data ON months.month = data.month
              ) t1
                  LEFT JOIN (
@@ -437,12 +458,25 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
                      LEFT JOIN (
                 SELECT
                     SUM(IFNULL(a.adjust_amount, a.rate_amount)) rate_amount,
-                    DATE_FORMAT(b.create_time, '%Y-%m') AS month
+                    DATE_FORMAT(d.create_time, '%Y-%m') AS month
                 FROM biz_waybill_cost_details a
-                    LEFT JOIN biz_waybill_order b ON a.external_waybill_no = b.external_waybill_no
-                WHERE b.order_status != 6
-                  AND b.dept_id = #{deptId}
-                GROUP BY DATE_FORMAT(b.create_time, '%Y-%m')
+                    LEFT JOIN biz_waybill_order d ON a.external_waybill_no = d.external_waybill_no
+                WHERE d.order_status != 6
+        <if test="orderType != null and orderType != ''">
+            and  d.order_type = #{orderType}
+        </if>
+        <if test="startDate != null and startDate != ''">
+            and DATE_FORMAT(d.create_time, '%Y-%m-%d') >= #{startDate}
+        </if>
+        <if test="endDate != null and endDate != ''">
+            and DATE_FORMAT(d.create_time, '%Y-%m-%d')<![CDATA[<=]]>  #{endDate}
+        </if>
+        <if test="deptId != null and deptId != ''">
+            AND d.dept_id = #{deptId}
+        </if>
+        <!-- 数据范围过滤 -->
+        ${params.dataScope}
+                GROUP BY DATE_FORMAT(d.create_time, '%Y-%m')
             ) data ON months.month = data.month
         ) t2 ON t1.month = DATE_FORMAT(STR_TO_DATE(CONCAT(t2.month, '-01'), '%Y-%m-%d') + INTERVAL 1 MONTH, '%Y-%m')
         ORDER BY t1.month;