Browse Source

分级权限查询

zangguocen 3 năm trước cách đây
mục cha
commit
fe248e9a74

+ 35 - 1
yijia-common/src/main/java/com/yijia/common/core/domain/BaseEntity.java

@@ -10,7 +10,7 @@ import com.fasterxml.jackson.annotation.JsonIgnore;
 
 /**
  * Entity基类
- * 
+ *
  * @author yijia
  */
 public class BaseEntity implements Serializable
@@ -45,9 +45,43 @@ public class BaseEntity implements Serializable
     @JsonIgnore
     private String endTime;
 
+    /**
+     * 站点id 查询传参用
+     */
+    private Long levelId;
+
     /** 请求参数 */
     private Map<String, Object> params;
 
+
+    private Integer pageNumLimit;
+
+    private Integer pageSizeLimit;
+
+    public Long getLevelId() {
+        return levelId;
+    }
+
+    public void setLevelId(Long levelId) {
+        this.levelId = levelId;
+    }
+
+    public Integer getPageNumLimit() {
+        return pageNumLimit;
+    }
+
+    public void setPageNumLimit(Integer pageNumLimit) {
+        this.pageNumLimit = pageNumLimit;
+    }
+
+    public Integer getPageSizeLimit() {
+        return pageSizeLimit;
+    }
+
+    public void setPageSizeLimit(Integer pageSizeLimit) {
+        this.pageSizeLimit = pageSizeLimit;
+    }
+
     /**
      * 根据用户所属组织,平台,集团,油站查询条件
      */

+ 10 - 0
yijia-common/src/main/java/com/yijia/common/core/domain/entity/SysDept.java

@@ -153,6 +153,16 @@ public class SysDept extends BaseEntity
     /**优惠劵是否共享*/
     private String  couponFlag;
 
+    private Long userId;
+
+    public Long getUserId() {
+        return userId;
+    }
+
+    public void setUserId(Long userId) {
+        this.userId = userId;
+    }
+
     public String getCouponFlag() {
         return couponFlag;
     }

+ 11 - 1
yijia-common/src/main/java/com/yijia/common/core/domain/entity/SysUser.java

@@ -17,7 +17,7 @@ import com.yijia.common.core.domain.BaseEntity;
 
 /**
  * 用户对象 sys_user
- * 
+ *
  * @author yijia
  */
 public class SysUser extends BaseEntity
@@ -96,6 +96,15 @@ public class SysUser extends BaseEntity
     {
 
     }
+    private String agentFlag;
+
+    public String getAgentFlag() {
+        return agentFlag;
+    }
+
+    public void setAgentFlag(String agentFlag) {
+        this.agentFlag = agentFlag;
+    }
 
     public SysUser(Long userId)
     {
@@ -323,6 +332,7 @@ public class SysUser extends BaseEntity
             .append("updateTime", getUpdateTime())
             .append("remark", getRemark())
             .append("dept", getDept())
+            .append("agentFlag", getAgentFlag())
             .toString();
     }
 }

+ 2 - 6
yijia-customer/src/main/java/com/yijia/customer/controller/CustomerCardUseRecordController.java

@@ -47,9 +47,7 @@ public class CustomerCardUseRecordController extends BaseController
     @GetMapping("/list")
     public TableDataInfo list(CustomerCardUseRecord customerCardUseRecord)
     {
-        LoginUser currentUser = SecurityUtils.getLoginUser();
-        SysDept sysDept = sysDeptService.selectDeptById(currentUser.getUser().getDeptId());
-        List<String> list = sysDeptService.deptCardInfoList(sysDept);
+        List<String> list = sysDeptService.levelDeptList(customerCardUseRecord.getLevelId());
         if(list!=null && list.size()>0){
             customerCardUseRecord.setStationIdList(list);
             customerCardUseRecord.setStationId(null);
@@ -66,9 +64,7 @@ public class CustomerCardUseRecordController extends BaseController
     @GetMapping(value = "/listCZXFData")
     public AjaxResult listCZXFData(CustomerCardUseRecord customerCardUseRecord)
     {
-        LoginUser currentUser = SecurityUtils.getLoginUser();
-        SysDept sysDept = sysDeptService.selectDeptById(currentUser.getUser().getDeptId());
-        List<String> list = sysDeptService.deptCardInfoList(sysDept);
+        List<String> list = sysDeptService.levelDeptList(customerCardUseRecord.getLevelId());
         if(list!=null && list.size()>0){
             customerCardUseRecord.setStationIdList(list);
             customerCardUseRecord.setStationId(null);

+ 12 - 19
yijia-customer/src/main/java/com/yijia/customer/controller/CustomerElectronicCardController.java

@@ -1,5 +1,6 @@
 package com.yijia.customer.controller;
 
+import java.util.ArrayList;
 import java.util.List;
 import com.yijia.common.constant.HttpStatus;
 import com.yijia.common.core.domain.entity.SysDept;
@@ -46,10 +47,7 @@ public class CustomerElectronicCardController extends BaseController
     @GetMapping("/list")
     public TableDataInfo list(CustomerElectronicCard customerElectronicCard)
     {
-        LoginUser currentUser = SecurityUtils.getLoginUser();
-        SysDept dept =new SysDept();
-        dept.setDeptId(currentUser.getUser().getDeptId());
-        List<String> list = deptService.selectDeptId(dept);
+        List<String> list = deptService.levelShareCardList(customerElectronicCard.getLevelId());
         if(list!=null && list.size()>0){
             customerElectronicCard.setStationIdList(list);
             customerElectronicCard.setStationId(null);
@@ -121,28 +119,27 @@ public class CustomerElectronicCardController extends BaseController
     @GetMapping("/listSum")
     public AjaxResult listSum(CustomerElectronicCard customerElectronicCard)
     {
-        LoginUser currentUser = SecurityUtils.getLoginUser();
-        SysDept sysDept = deptService.selectDeptById(currentUser.getUser().getDeptId());
-        List<String> list = deptService.deptCardInfoList(sysDept);
+        List<String> list = deptService.levelShareCardList(customerElectronicCard.getLevelId());
         if(list!=null && list.size()>0){
             customerElectronicCard.setStationIdList(list);
             customerElectronicCard.setStationId(null);
         }
-        return AjaxResult.success(customerElectronicCardService.listSum(customerElectronicCard));
+        CustomerElectronicCard card = customerElectronicCardService.listSum(customerElectronicCard);
+        return AjaxResult.success(card);
     }
     @GetMapping("/selectCard")
     public TableDataInfo selectCard(CustomerElectronicCard customerElectronicCard)
     {
-        LoginUser currentUser = SecurityUtils.getLoginUser();
-        SysDept sysDept = deptService.selectDeptById(currentUser.getUser().getDeptId());
-        List<String> list = deptService.deptCardInfoList(sysDept);
+        List<String> list = deptService.levelShareCardList(customerElectronicCard.getLevelId());
+        List<CustomerElectronicCard> querylist =new ArrayList<>();
+        List<CustomerElectronicCard> pagelist =new ArrayList<>();
         if(list!=null && list.size()>0){
             customerElectronicCard.setStationIdList(list);
             customerElectronicCard.setStationId(null);
             customerElectronicCard.setStrSql(StringUtils.join(list, ","));
+            querylist= customerElectronicCardService.selectCard(customerElectronicCard) ;
+            pagelist = customerElectronicCardService.selectCardPage(customerElectronicCard) ;
         }
-        List<CustomerElectronicCard>  querylist= customerElectronicCardService.selectCard(customerElectronicCard) ;
-        List<CustomerElectronicCard> pagelist = customerElectronicCardService.selectCardPage(customerElectronicCard) ;
         TableDataInfo rspData = new TableDataInfo();
         rspData.setCode(HttpStatus.SUCCESS);
         rspData.setMsg("查询成功");
@@ -156,9 +153,7 @@ public class CustomerElectronicCardController extends BaseController
     @GetMapping("/listHYData")
     public AjaxResult listHYData(CustomerElectronicCard customerElectronicCard)
     {
-        LoginUser currentUser = SecurityUtils.getLoginUser();
-        SysDept sysDept = deptService.selectDeptById(currentUser.getUser().getDeptId());
-        List<String> list = deptService.deptCardInfoList(sysDept);
+        List<String> list = deptService.levelDeptList(customerElectronicCard.getLevelId());
         if(list!=null && list.size()>0){
             customerElectronicCard.setStationIdList(list);
             customerElectronicCard.setStationId(null);
@@ -172,9 +167,7 @@ public class CustomerElectronicCardController extends BaseController
     @GetMapping("/listJRHYData")
     public AjaxResult listJRHYData(CustomerElectronicCard customerElectronicCard)
     {
-        LoginUser currentUser = SecurityUtils.getLoginUser();
-        SysDept sysDept = deptService.selectDeptById(currentUser.getUser().getDeptId());
-        List<String> list = deptService.deptCardInfoList(sysDept);
+        List<String> list = deptService.levelDeptList(customerElectronicCard.getLevelId());
         if(list!=null && list.size()>0){
             customerElectronicCard.setStationIdList(list);
             customerElectronicCard.setStationId(null);

+ 2 - 8
yijia-customer/src/main/java/com/yijia/customer/controller/CustomerManageController.java

@@ -52,10 +52,7 @@ public class CustomerManageController extends BaseController
     @GetMapping("/list")
     public TableDataInfo list(CustomerManage customerManage)
     {
-        LoginUser currentUser = SecurityUtils.getLoginUser();
-        SysDept dept =new SysDept();
-        dept.setDeptId(currentUser.getUser().getDeptId());
-        List<String> list = deptService.selectDeptId(dept);
+        List<String> list = deptService.levelDeptList(customerManage.getLevelId());
         if(list!=null && list.size()>0){
             customerManage.setStationIdList(list);
             customerManage.setStationId(null);
@@ -88,10 +85,7 @@ public class CustomerManageController extends BaseController
     @GetMapping("/export")
     public AjaxResult export(CustomerManage customerManage)
     {
-        LoginUser currentUser = SecurityUtils.getLoginUser();
-        SysDept dept =new SysDept();
-        dept.setDeptId(currentUser.getUser().getDeptId());
-        List<String> list = deptService.selectDeptId(dept);
+        List<String> list = deptService.levelDeptList(customerManage.getLevelId());
         if(list!=null && list.size()>0){
             customerManage.setStationIdList(list);
             customerManage.setStationId(null);

+ 22 - 19
yijia-customer/src/main/resources/mapper/customer/CustomerElectronicCardMapper.xml

@@ -110,25 +110,28 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
     </delete>
 
     <select id="listSum" parameterType="CustomerElectronicCard" resultMap="CustomerElectronicCardResult">
-        SELECT count(DISTINCT union_id) as num,sum(amt) as amt
-        from customer_electronic_card
-        <where>
-            <if test="unionId != null  and unionId != ''"> and union_id = #{unionId}</if>
-            <if test="customerNo != null  and customerNo != ''"> and customer_no = #{customerNo}</if>
-            <if test="customerName != null  and customerName != ''"> and customer_name like concat('%', #{customerName}, '%')</if>
-            <if test="mobilePhone != null  and mobilePhone != ''"> and mobile_phone = #{mobilePhone}</if>
-            <if test="amt != null "> and amt = #{amt}</if>
-            <if test="cardOilsType != null  and cardOilsType != ''"> and card_oils_type = #{cardOilsType}</if>
-            <if test="stationId != null "> and station_id = #{stationId}</if>
-            <if test="recentlyTime != null "> and recently_time = #{recentlyTime}</if>
-            <if test="stationIdList != null ">
-                and station_id in
-                <foreach item="item" index="index" collection="stationIdList"
-                         open="(" separator="," close=")">
-                    #{item}
-                </foreach>
-            </if>
-        </where>
+        SELECT sum(a.num) as num,sum(a.amt) as amt
+        from (
+            SELECT count(DISTINCT union_id) as num,sum(amt) as amt
+            from  customer_electronic_card
+            <where>
+                <if test="unionId != null  and unionId != ''"> and union_id = #{unionId}</if>
+                <if test="customerNo != null  and customerNo != ''"> and customer_no = #{customerNo}</if>
+                <if test="customerName != null  and customerName != ''"> and customer_name like concat('%', #{customerName}, '%')</if>
+                <if test="mobilePhone != null  and mobilePhone != ''"> and mobile_phone = #{mobilePhone}</if>
+                <if test="amt != null "> and amt = #{amt}</if>
+                <if test="cardOilsType != null  and cardOilsType != ''"> and card_oils_type = #{cardOilsType}</if>
+                <if test="stationId != null "> and station_id = #{stationId}</if>
+                <if test="recentlyTime != null "> and recently_time = #{recentlyTime}</if>
+                <if test="stationIdList != null ">
+                    and station_id in
+                    <foreach item="item" index="index" collection="stationIdList"
+                             open="(" separator="," close=")">
+                        #{item}
+                    </foreach>
+                </if>
+            </where>
+            GROUP BY station_id ) a
     </select>
 
     <select id="listHYData" parameterType="CustomerElectronicCard" resultMap="CustomerElectronicCardResult">