Pārlūkot izejas kodu

查询专利号带筛选 2022/12/14

lwhhszx 2 gadi atpakaļ
vecāks
revīzija
cb7d328643

+ 64 - 0
PAS/src/main/java/cn/cslg/pas/common/core/annotation/LoggerAspect.java

@@ -0,0 +1,64 @@
+package cn.cslg.pas.common.core.annotation;
+
+
+import cn.cslg.pas.common.utils.JsonUtils;
+import lombok.extern.slf4j.Slf4j;
+import org.aspectj.lang.JoinPoint;
+import org.aspectj.lang.ProceedingJoinPoint;
+import org.aspectj.lang.annotation.AfterThrowing;
+import org.aspectj.lang.annotation.Around;
+import org.aspectj.lang.annotation.Aspect;
+import org.aspectj.lang.annotation.Pointcut;
+import org.springframework.core.annotation.Order;
+import org.springframework.stereotype.Component;
+
+@Order(3)
+@Aspect
+@Component
+@Slf4j
+public class LoggerAspect {
+
+
+    /**
+     * 定义切点
+     */
+    @Pointcut("execution( * cn.cslg.pas.controller..*.*(..))")
+    public void annotationPointcut() {
+
+    }
+
+    /**
+     * @param joinPoint 当前执行的方法
+     */
+    @Around("annotationPointcut()")
+    public Object doAround(ProceedingJoinPoint joinPoint) throws Throwable {
+
+        //判断通过
+        return joinPoint.proceed();
+    }
+
+    @AfterThrowing(pointcut = "annotationPointcut()",throwing = "e")
+    public void doAfterThrowing(JoinPoint joinPoint, Throwable e){
+
+        //获取用户请求方法的参数并序列化为JSON格式字符串
+        String params = "";
+        if (joinPoint.getArgs()!=null&&joinPoint.getArgs().length>0){
+            for (int i = 0; i < joinPoint.getArgs().length; i++) {
+                params+= JsonUtils.objectToJson(joinPoint.getArgs()[i])+";";
+            }
+        }
+        try{
+            String str1 ="异常代码:" + e.getClass().getName();
+            String str2 ="异常信息:" + e.getMessage();
+            String str3="异常方法:" + (joinPoint.getTarget().getClass().getName() + "." + joinPoint.getSignature().getName() + "()");
+            String str4="请求参数:" + params; System.out.println("异常代码:" + e.getClass().getName());
+   log.error(str1+"\r"+str2+"\r"+str3+"\r"+str4);
+        }catch (Exception ex){
+            //记录本地异常日志
+            log.error("==异常通知异常==");
+            log.error("异常信息:{}", ex.getMessage());
+        }
+    }
+
+}
+

+ 2 - 1
PAS/src/main/java/cn/cslg/pas/mapper/ProjectMapper.java

@@ -5,6 +5,7 @@ import cn.cslg.pas.common.model.vo.ProjectVO;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import org.apache.ibatis.annotations.Param;
 
 import java.util.List;
 
@@ -19,5 +20,5 @@ import java.util.List;
 public interface ProjectMapper extends BaseMapper<Project> {
 
     IPage<Project> getPageList(Page<Project> page, ProjectVO params);
-    List<Project> getListForCount();
+    List<Project> getListForCount(@Param("params") ProjectVO params);
 }

+ 9 - 3
PAS/src/main/java/cn/cslg/pas/service/ProjectService.java

@@ -241,9 +241,15 @@ public class ProjectService extends ServiceImpl<ProjectMapper, Project> {
     }
 
     public List<Project> getAllProjectByMySelf() {
-        //使用专题库查询的权限查询,因为要使用专题库的权限,因此查询语句格式需要和专题库查询的格式统一,所以手写了查询语句
-        securityUtils.startDataScope("/workspace/project/check");
-        List<Project> projectList = baseMapper.getListForCount();
+        ProjectVO params=new ProjectVO();
+        PersonnelVO personnelVO = cacheUtils.getLoginUser(loginUtils.getId());
+        if (personnelVO.getRoleType() == null || personnelVO.getRoleType() != 1) {
+            params.setPersonnelId(loginUtils.getId());
+            if (personnelVO.getRoleType() != null && personnelVO.getRoleType() == 2) {
+                params.setTenantId(personnelVO.getTenantId());
+            }
+        }
+        List<Project> projectList = baseMapper.getListForCount(params);
         this.setDataList(projectList);
         return projectList;
     }

+ 9 - 4
PAS/src/main/resources/mapper/ProjectMapper.xml

@@ -14,7 +14,6 @@
         left join os_distribution u on u.id = a.creat_id
         left join os_client b on b.id = a.clientid
         <where>
-            1=1
             <if test="params.name != '' and params.name != null">
                 and a.name like concat('%', #{params.name}, '%')
             </if>
@@ -56,7 +55,7 @@
         <if test="params.PersonnelId!=null">
           and  a.id in (select tid from os_distribution_doing where uid=#{params.PersonnelId} )
         <if test="params.tenantId!=null">
-            or a.tenantId = #{params.tenantId}
+            and a.tenantId = #{params.tenantId}
         </if>
         </if>
         </where>
@@ -64,7 +63,8 @@
     </select>
 
     <select id="getListForCount"
-            resultType="cn.cslg.pas.domain.Project">
+            resultType="cn.cslg.pas.domain.Project"
+            parameterType="cn.cslg.pas.common.model.vo.ProjectVO">
         select  a.id, a.`name`, a.creat_id as create_by, a.technical_theme,
         a.innerfile as inner_file, a.`update`, a.`status`, a.contract_no,
         a.`case` as case_date, a.update_time, a.sort, a.clientid as client_id,
@@ -72,7 +72,12 @@
 
         from os_thematic a
         <where>
-            1=1
+            <if test="params.PersonnelId!=null">
+                and  a.id in (select tid from os_distribution_doing where uid=#{params.PersonnelId} )
+                <if test="params.tenantId!=null">
+                    and a.tenantId = #{params.tenantId}
+                </if>
+            </if>
         </where>
 
     </select>