From 1045f256c2d9477b177dec61246bc0d174133f97 Mon Sep 17 00:00:00 2001
From: xiangpei <xiangpei@timesnew.cn>
Date: 星期一, 20 一月 2025 18:02:49 +0800
Subject: [PATCH] Query适配数据权限、项目查询增加数据权限

---
 flowable/src/main/java/com/ycl/service/IFlowTaskService.java               |    2 
 start/src/main/resources/application-dev.yml                               |    2 
 business/src/main/resources/mapper/ProjectInfoMapper.xml                   |   11 ++++-
 business/src/main/java/com/ycl/mapper/PlanMapper.java                      |    4 +
 flowable/src/main/java/com/ycl/service/impl/FlowTaskServiceImpl.java       |    2 
 business/src/main/java/com/ycl/mapper/ProjectInfoMapper.java               |    8 +++-
 flowable/src/main/java/com/ycl/controller/FlowTaskController.java          |   10 ++--
 business/src/main/resources/mapper/PlanMapper.xml                          |    2 +
 business/src/main/resources/mapper/ProjectProcessMapper.xml                |    2 +
 system/src/main/java/com/ycl/system/domain/base/AbsQuery.java              |    5 ++
 system/src/main/java/com/ycl/framework/aspectj/DataScopeAspect.java        |    8 +++-
 business/src/main/java/com/ycl/service/impl/ProjectInfoServiceImpl.java    |   24 ++++++-----
 business/src/main/java/com/ycl/service/impl/ProjectProcessServiceImpl.java |    3 +
 business/src/main/java/com/ycl/service/impl/PlanServiceImpl.java           |    2 
 business/src/main/java/com/ycl/mapper/ProjectProcessMapper.java            |    4 +
 business/src/main/java/com/ycl/domain/vo/ProjectProcessVO.java             |    3 +
 16 files changed, 63 insertions(+), 29 deletions(-)

diff --git a/business/src/main/java/com/ycl/domain/vo/ProjectProcessVO.java b/business/src/main/java/com/ycl/domain/vo/ProjectProcessVO.java
index b4353b7..703f8e9 100644
--- a/business/src/main/java/com/ycl/domain/vo/ProjectProcessVO.java
+++ b/business/src/main/java/com/ycl/domain/vo/ProjectProcessVO.java
@@ -25,6 +25,9 @@
     @ApiModelProperty("娴佺▼瀹氫箟id")
     private String processDefId;
 
+    @ApiModelProperty("鍙戝竷id")
+    private String deployId;
+
     @ApiModelProperty("娴佺▼鍚嶇О")
     private String flowableProcessName;
 
diff --git a/business/src/main/java/com/ycl/mapper/PlanMapper.java b/business/src/main/java/com/ycl/mapper/PlanMapper.java
index 1e2695b..de4a871 100644
--- a/business/src/main/java/com/ycl/mapper/PlanMapper.java
+++ b/business/src/main/java/com/ycl/mapper/PlanMapper.java
@@ -2,6 +2,7 @@
 
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.ycl.common.annotation.DataScope;
 import com.ycl.domain.entity.Plan;
 import com.ycl.domain.query.PlanQuery;
 import com.ycl.domain.vo.PlanVO;
@@ -27,6 +28,7 @@
     /**
     *  鍒嗛〉
     */
-    IPage getPage(IPage page, @Param("query") PlanQuery query);
+    @DataScope(deptAlias = "d")
+    IPage getPage(@Param("query") PlanQuery query, IPage page);
 
 }
diff --git a/business/src/main/java/com/ycl/mapper/ProjectInfoMapper.java b/business/src/main/java/com/ycl/mapper/ProjectInfoMapper.java
index 0a1b711..f3b4467 100644
--- a/business/src/main/java/com/ycl/mapper/ProjectInfoMapper.java
+++ b/business/src/main/java/com/ycl/mapper/ProjectInfoMapper.java
@@ -2,6 +2,8 @@
 
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.ycl.common.annotation.DataScope;
+import com.ycl.common.core.domain.BaseEntity;
 import com.ycl.domain.entity.ProjectInfo;
 import com.ycl.domain.excel.ProjectExcelTemplate;
 import com.ycl.domain.query.ProjectInfoQuery;
@@ -31,9 +33,11 @@
     /**
     *  鍒嗛〉
     */
-    IPage getPage(IPage page, @Param("query") ProjectInfoQuery query);
+    @DataScope(deptAlias = "d")
+    IPage getPage(@Param("query") ProjectInfoQuery query, IPage page);
 
-    List<ProjectVO> homeCount();
+    @DataScope(deptAlias = "d")
+    List<ProjectVO> homeCount(BaseEntity params);
 
     List<ProjectVO> selectProjectDetailByIds(@Param("dataIdList") List<Long> dataIdList);
 
diff --git a/business/src/main/java/com/ycl/mapper/ProjectProcessMapper.java b/business/src/main/java/com/ycl/mapper/ProjectProcessMapper.java
index 76bb113..64405b6 100644
--- a/business/src/main/java/com/ycl/mapper/ProjectProcessMapper.java
+++ b/business/src/main/java/com/ycl/mapper/ProjectProcessMapper.java
@@ -1,5 +1,6 @@
 package com.ycl.mapper;
 
+import com.ycl.common.annotation.DataScope;
 import com.ycl.domain.entity.ProjectInfo;
 import com.ycl.domain.entity.ProjectProcess;
 import com.baomidou.mybatisplus.core.metadata.IPage;
@@ -30,7 +31,8 @@
     /**
     *  鍒嗛〉
     */
-    IPage getPage(IPage page, @Param("query") ProjectProcessQuery query);
+    @DataScope(deptAlias = "d")
+    IPage getPage(@Param("query") ProjectProcessQuery query, IPage page);
 
     /**
      * 閫氳繃娴佺▼瀹炰緥id鑾峰彇椤圭洰id銆佸悕绉�
diff --git a/business/src/main/java/com/ycl/service/impl/PlanServiceImpl.java b/business/src/main/java/com/ycl/service/impl/PlanServiceImpl.java
index 4a161da..a8a5814 100644
--- a/business/src/main/java/com/ycl/service/impl/PlanServiceImpl.java
+++ b/business/src/main/java/com/ycl/service/impl/PlanServiceImpl.java
@@ -105,7 +105,7 @@
     @Override
     public Result page(PlanQuery query) {
         IPage<ProjectPlanResponseVO> page = PageUtil.getPage(query, ProjectPlanResponseVO.class);
-        baseMapper.getPage(page, query);
+        baseMapper.getPage(query, page);
         // 瀵瑰垎椤靛悗鐨勫睘鎬ц繘琛屽鐞�
         List<ProjectPlanResponseVO> records = page.getRecords();
         for (ProjectPlanResponseVO record : records) {
diff --git a/business/src/main/java/com/ycl/service/impl/ProjectInfoServiceImpl.java b/business/src/main/java/com/ycl/service/impl/ProjectInfoServiceImpl.java
index 2d11117..d2c2534 100644
--- a/business/src/main/java/com/ycl/service/impl/ProjectInfoServiceImpl.java
+++ b/business/src/main/java/com/ycl/service/impl/ProjectInfoServiceImpl.java
@@ -13,9 +13,11 @@
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.ycl.common.annotation.DataScope;
 import com.ycl.common.base.Result;
 import com.ycl.common.config.SysConfig;
 import com.ycl.common.constant.Constants;
+import com.ycl.common.core.domain.BaseEntity;
 import com.ycl.common.enums.business.FileTypeEnum;
 import com.ycl.common.enums.business.ImportanceTypeEnum;
 import com.ycl.common.enums.business.ProjectCategoryEnum;
@@ -233,18 +235,18 @@
         Long userId = SecurityUtils.getUserId();
         String ancestors = sysDeptMapper.selectAncestors(userId);
         String[] ancestorArr = ancestors.split(",");
-        for (String ancestor : ancestorArr) {
-            if ("101".equals(ancestor)) { // 涓氫富
-                query.setCreateBy(userId);
-                query.setRole(0);
-            } else if ("102".equals(ancestor)) { // 瀹℃壒
-                query.setUsedStatus(1);
-                query.setRole(1);
-            }
-        }
+//        for (String ancestor : ancestorArr) {
+//            if ("101".equals(ancestor)) { // 涓氫富
+//                query.setCreateBy(userId);
+//                query.setRole(0);
+//            } else if ("102".equals(ancestor)) { // 瀹℃壒
+//                query.setUsedStatus(1);
+//                query.setRole(1);
+//            }
+//        }
 
         IPage<ProjectInfoVO> page = PageUtil.getPage(query, ProjectInfoVO.class);
-        baseMapper.getPage(page, query);
+        baseMapper.getPage(query, page);
         List<ProjectInfoVO> records = page.getRecords();
         List<ProjectVO> list = new ArrayList<>();
         records.forEach(vo -> {
@@ -315,7 +317,7 @@
         // {"type":"鐪侀噸鐐归」鐩�","count":0,"amount":"0.00","text":"鐪�"}]}}
         IndexCountVO indexCountVO = new IndexCountVO();
         List<IndexProPhaseCountVO> proPhaseCountVO = new ArrayList<>();
-        List<ProjectVO> projectVOS = baseMapper.homeCount();
+        List<ProjectVO> projectVOS = baseMapper.homeCount(new BaseEntity());
         List<ProjectVO> reserve = new ArrayList<>();
         List<ProjectVO> previous = new ArrayList<>();
         List<ProjectVO> implement = new ArrayList<>();
diff --git a/business/src/main/java/com/ycl/service/impl/ProjectProcessServiceImpl.java b/business/src/main/java/com/ycl/service/impl/ProjectProcessServiceImpl.java
index 15f8119..473bb14 100644
--- a/business/src/main/java/com/ycl/service/impl/ProjectProcessServiceImpl.java
+++ b/business/src/main/java/com/ycl/service/impl/ProjectProcessServiceImpl.java
@@ -90,13 +90,14 @@
     @Override
     public Result page(ProjectProcessQuery query) {
         IPage<ProjectProcessVO> page = PageUtil.getPage(query, ProjectProcessVO.class);
-        baseMapper.getPage(page, query);
+        baseMapper.getPage(query, page);
         for (ProjectProcessVO vo : page.getRecords()) {
             if (Objects.nonNull(vo.getProcessDefId())) {
                 ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery().processDefinitionId(vo.getProcessDefId()).singleResult();
                 if (Objects.nonNull(processDefinition)) {
                     vo.setSuspended(processDefinition.isSuspended());
                     vo.setFlowableProcessName(processDefinition.getName() + "(v" + processDefinition.getVersion() + ")");
+                    vo.setDeployId(processDefinition.getDeploymentId());
                 }
             }
         }
diff --git a/business/src/main/resources/mapper/PlanMapper.xml b/business/src/main/resources/mapper/PlanMapper.xml
index 0b433f7..139c557 100644
--- a/business/src/main/resources/mapper/PlanMapper.xml
+++ b/business/src/main/resources/mapper/PlanMapper.xml
@@ -63,6 +63,7 @@
             pi.invest_type
         FROM t_project_info AS pi
         LEFT JOIN t_plan AS p ON p.project_info_id = pi.id
+        LEFT JOIN sys_dept d ON d.dept_id = PI.project_owner_unit
         <where>
             pi.deleted = 0
             <if test="query.projectName!= null and query.projectName!= ''">
@@ -83,6 +84,7 @@
             <if test="query.yearStatus!= null">
                 AND p.year_status = #{query.yearStatus}
             </if>
+            ${query.params.dataScope}
         </where>
     </select>
 
diff --git a/business/src/main/resources/mapper/ProjectInfoMapper.xml b/business/src/main/resources/mapper/ProjectInfoMapper.xml
index b02a2b9..d196b96 100644
--- a/business/src/main/resources/mapper/ProjectInfoMapper.xml
+++ b/business/src/main/resources/mapper/ProjectInfoMapper.xml
@@ -103,6 +103,7 @@
         LEFT JOIN t_project_investment_policy_compliance TPIPC ON TPI.id = TPIPC.project_id and TPIPC.deleted = 0
         LEFT JOIN t_project_unit_registration_info TPURI ON TPI.id = TPURI.project_id and TPURI.deleted = 0
         LEFT JOIN t_project_process TPP ON TPI.id = TPP.project_id and TPP.deleted = 0
+        LEFT JOIN sys_dept d ON d.dept_id = TPI.project_owner_unit
         <where>
             TPI.deleted = 0
             <if test="query.projectName !=null and query.projectName!=''">
@@ -164,16 +165,22 @@
                     and TPI.used_status = #{query.usedStatus}
                 </if>
             </if>
+            ${query.params.dataScope}
         </where>
         order by TPI.gmt_create
     </select>
 
-    <select id="homeCount" resultType="com.ycl.domain.vo.ProjectVO">
+    <select id="homeCount" parameterType="com.ycl.common.core.domain.BaseEntity" resultType="com.ycl.domain.vo.ProjectVO">
         SELECT TPI.*,TPIF.total_investment,TPP.process_ins_id as processId
         FROM t_project_info TPI
         LEFT JOIN t_project_investment_funding TPIF ON TPI.id = TPIF.project_id and TPIF.deleted = 0
         LEFT JOIN t_project_process TPP ON TPI.id = TPP.project_id and TPP.deleted = 0
-        WHERE TPI.deleted = 0
+        LEFT JOIN sys_dept d ON TPI.project_owner_unit = d.dept_id
+        <where>
+            TPI.deleted = 0
+            ${params.dataScope}
+        </where>
+
     </select>
 
     <select id="selectProjectDetailByIds" resultType="com.ycl.domain.vo.ProjectVO">
diff --git a/business/src/main/resources/mapper/ProjectProcessMapper.xml b/business/src/main/resources/mapper/ProjectProcessMapper.xml
index aa8f67a..37c80a6 100644
--- a/business/src/main/resources/mapper/ProjectProcessMapper.xml
+++ b/business/src/main/resources/mapper/ProjectProcessMapper.xml
@@ -65,6 +65,7 @@
         FROM
             t_project_info PI
                 LEFT JOIN t_project_process TPP ON TPP.project_id = PI.id AND TPP.deleted = 0 AND PI.deleted = 0
+                LEFT JOIN sys_dept d ON d.dept_id = PI.project_owner_unit
         <where>
             <if test="query.projectName != null and query.projectName != ''">
                 AND PI.project_name like concat('%', #{query.projectName}, '%')
@@ -72,6 +73,7 @@
             <if test="query.projectCode != null and query.projectCode != ''">
                 AND PI.project_code like concat('%', #{query.projectCode}, '%')
             </if>
+            ${query.params.dataScope}
         </where>
 
     </select>
diff --git a/flowable/src/main/java/com/ycl/controller/FlowTaskController.java b/flowable/src/main/java/com/ycl/controller/FlowTaskController.java
index 4a23d6f..2232c0f 100644
--- a/flowable/src/main/java/com/ycl/controller/FlowTaskController.java
+++ b/flowable/src/main/java/com/ycl/controller/FlowTaskController.java
@@ -75,8 +75,8 @@
 
     @ApiOperation(value = "娴佺▼鍘嗗彶娴佽浆璁板綍", response = FlowTaskDto.class)
     @GetMapping(value = "/flowRecord")
-    public AjaxResult flowRecord(String procInsId, String deployId) {
-        return flowTaskService.flowRecord(procInsId, deployId);
+    public AjaxResult flowRecord(String procInsId) {
+        return flowTaskService.flowRecord(procInsId);
     }
 
     @ApiOperation(value = "鏍规嵁浠诲姟ID鏌ヨ鎸傝浇鐨勮〃鍗曚俊鎭�")
@@ -258,13 +258,13 @@
     /**
      * 娴佺▼鑺傜偣淇℃伅
      *
-     * @param procInsId 娴佺▼瀹炰緥id
+     * @param processInsId 娴佺▼瀹炰緥id
      * @return
      */
     @GetMapping("/flowXmlAndNode")
-    public AjaxResult flowXmlAndNode(@RequestParam(value = "procInsId", required = false) String procInsId,
+    public AjaxResult flowXmlAndNode(@RequestParam(value = "processInsId", required = false) String processInsId,
                                      @RequestParam(value = "deployId", required = false) String deployId) {
-        return flowTaskService.flowXmlAndNode(procInsId, deployId);
+        return flowTaskService.flowXmlAndNode(processInsId, deployId);
     }
 
     /**
diff --git a/flowable/src/main/java/com/ycl/service/IFlowTaskService.java b/flowable/src/main/java/com/ycl/service/IFlowTaskService.java
index 35f11b5..393fc17 100644
--- a/flowable/src/main/java/com/ycl/service/IFlowTaskService.java
+++ b/flowable/src/main/java/com/ycl/service/IFlowTaskService.java
@@ -145,7 +145,7 @@
      * @param procInsId 娴佺▼瀹炰緥Id
      * @return
      */
-    AjaxResult flowRecord(String procInsId,String deployId);
+    AjaxResult flowRecord(String procInsId);
 
     /**
      * 鏍规嵁浠诲姟ID鏌ヨ鎸傝浇鐨勮〃鍗曚俊鎭�
diff --git a/flowable/src/main/java/com/ycl/service/impl/FlowTaskServiceImpl.java b/flowable/src/main/java/com/ycl/service/impl/FlowTaskServiceImpl.java
index ef68382..32f9399 100644
--- a/flowable/src/main/java/com/ycl/service/impl/FlowTaskServiceImpl.java
+++ b/flowable/src/main/java/com/ycl/service/impl/FlowTaskServiceImpl.java
@@ -800,7 +800,7 @@
      * @return
      */
     @Override
-    public AjaxResult flowRecord(String procInsId, String deployId) {
+    public AjaxResult flowRecord(String procInsId) {
         Map<String, Object> map = new HashMap<String, Object>();
         if (StringUtils.isNotBlank(procInsId)) {
             List<HistoricActivityInstance> list = historyService
diff --git a/start/src/main/resources/application-dev.yml b/start/src/main/resources/application-dev.yml
index c288bd0..fafad6b 100644
--- a/start/src/main/resources/application-dev.yml
+++ b/start/src/main/resources/application-dev.yml
@@ -7,7 +7,7 @@
     # 鐗堟潈骞翠唤
     copyrightYear: 2024
     # 鏂囦欢璺緞 绀轰緥锛� Windows閰嶇疆D:/projectManagement/uploadPath锛孡inux閰嶇疆 /home/projectManagement/uploadPath锛�
-    profile: D:/projectManagement/uploadPath
+    profile: E:/ycl/file
     # 鑾峰彇ip鍦板潃寮�鍏�
     addressEnabled: false
     # 楠岃瘉鐮佺被鍨� math 鏁板瓧璁$畻 char 瀛楃楠岃瘉
diff --git a/system/src/main/java/com/ycl/framework/aspectj/DataScopeAspect.java b/system/src/main/java/com/ycl/framework/aspectj/DataScopeAspect.java
index 8ae1e70..7c9cf60 100644
--- a/system/src/main/java/com/ycl/framework/aspectj/DataScopeAspect.java
+++ b/system/src/main/java/com/ycl/framework/aspectj/DataScopeAspect.java
@@ -2,6 +2,8 @@
 
 import java.util.ArrayList;
 import java.util.List;
+
+import com.ycl.system.domain.base.AbsQuery;
 import org.aspectj.lang.JoinPoint;
 import org.aspectj.lang.annotation.Aspect;
 import org.aspectj.lang.annotation.Before;
@@ -151,10 +153,12 @@
         if (StringUtils.isNotBlank(sqlString.toString()))
         {
             Object params = joinPoint.getArgs()[0];
-            if (StringUtils.isNotNull(params) && params instanceof BaseEntity)
-            {
+            if (StringUtils.isNotNull(params) && params instanceof BaseEntity) {
                 BaseEntity baseEntity = (BaseEntity) params;
                 baseEntity.getParams().put(DATA_SCOPE, " AND (" + sqlString.substring(4) + ")");
+            } else if (StringUtils.isNotNull(params) && params instanceof AbsQuery) {
+                AbsQuery query = (AbsQuery) params;
+                query.getParams().put(DATA_SCOPE, " AND (" + sqlString.substring(4) + ")");
             }
         }
     }
diff --git a/system/src/main/java/com/ycl/system/domain/base/AbsQuery.java b/system/src/main/java/com/ycl/system/domain/base/AbsQuery.java
index 940053d..909f96b 100644
--- a/system/src/main/java/com/ycl/system/domain/base/AbsQuery.java
+++ b/system/src/main/java/com/ycl/system/domain/base/AbsQuery.java
@@ -3,6 +3,9 @@
 import io.swagger.annotations.ApiModelProperty;
 import lombok.Data;
 
+import java.util.HashMap;
+import java.util.Map;
+
 /**
  * 鍩虹鍒嗛〉鏌ヨ锛岄粯璁ょ涓�椤碉紝姣忛〉10鏉�
  *
@@ -18,4 +21,6 @@
     @ApiModelProperty(value = "姣忛〉鏉℃暟", required = true)
     private long pageSize = 10L;
 
+    public Map<String, Object> params = new HashMap<>(2);
+
 }

--
Gitblit v1.8.0