Browse Source

SAI分页优化

wangggziwen 1 năm trước cách đây
mục cha
commit
c5fb3028fb

+ 30 - 4
master/src/main/java/com/ruoyi/project/production/controller/TSaiApplyController.java

@@ -1,19 +1,27 @@
 package com.ruoyi.project.production.controller;
 
 import com.alibaba.fastjson.JSON;
+import com.github.pagehelper.PageHelper;
 import com.github.stuxuhai.jpinyin.PinyinException;
+import com.ruoyi.common.constant.HttpStatus;
 import com.ruoyi.common.sendEmail.IMailService;
 import com.ruoyi.common.thread.Trainning.MeetingInvitationMailThread;
 import com.ruoyi.common.thread.sai.SaiApplyMailThread;
 import com.ruoyi.common.utils.DateUtils;
+import com.ruoyi.common.utils.ServletUtils;
 import com.ruoyi.common.utils.file.ExcelUtils;
 import com.ruoyi.common.utils.poi.ExcelUtil;
+import com.ruoyi.common.utils.spring.SpringUtils;
 import com.ruoyi.framework.aspectj.lang.annotation.Log;
 import com.ruoyi.framework.aspectj.lang.enums.BusinessType;
 import com.ruoyi.framework.interceptor.annotation.RepeatSubmit;
+import com.ruoyi.framework.security.LoginUser;
+import com.ruoyi.framework.security.service.TokenService;
 import com.ruoyi.framework.web.controller.BaseController;
 import com.ruoyi.framework.web.domain.AjaxResult;
+import com.ruoyi.framework.web.page.PageDomain;
 import com.ruoyi.framework.web.page.TableDataInfo;
+import com.ruoyi.framework.web.page.TableSupport;
 import com.ruoyi.project.approve.damain.DevTask;
 import com.ruoyi.project.plant.domain.TStaffmgr;
 import com.ruoyi.project.plant.service.ITStaffmgrService;
@@ -25,10 +33,7 @@ import com.ruoyi.project.production.domain.TSaiApproveFile;
 import com.ruoyi.project.production.service.ITSaiApplyService;
 import com.ruoyi.project.production.service.ITSaiApproveFileService;
 import com.ruoyi.project.sems.domain.TApproverFile;
-import com.ruoyi.project.system.domain.SysDept;
-import com.ruoyi.project.system.domain.SysDictData;
-import com.ruoyi.project.system.domain.SysMessage;
-import com.ruoyi.project.system.domain.SysUser;
+import com.ruoyi.project.system.domain.*;
 import com.ruoyi.project.system.mapper.SysDeptMapper;
 import com.ruoyi.project.system.mapper.SysUserMapper;
 import com.ruoyi.project.system.service.ISysDeptService;
@@ -105,11 +110,32 @@ public class TSaiApplyController extends BaseController
     @GetMapping("/list")
     public TableDataInfo list(SaiApplyQueryVO tSaiApply)
     {
+        tSaiApply.setCurrentUser(getUserId());
+        tSaiApply.setSpecialRole(this.isSpecialRole());
         startPage();
         List<TSaiApply> list = tSaiApplyService.selectTSaiApplyList(tSaiApply);
         return getDataTable(list);
     }
 
+    /**
+     * 当前登录用户是否为特殊角色(供SAI功能展示使用)
+     *
+     * @return 是否为特殊角色
+     */
+    private boolean isSpecialRole() {
+        boolean isSpecialRole = false;
+        LoginUser loginUser = SpringUtils.getBean(TokenService.class).getLoginUser(ServletUtils.getRequest());
+        SysUser user = loginUser.getUser();
+        List<SysRole> roles = user.getRoles();
+        for (SysRole role : roles) {
+            Long roleId = role.getRoleId();
+            if (roleId.toString().equals("23140")) {
+                isSpecialRole = true;
+            }
+        }
+        return isSpecialRole;
+    }
+
     /**
      * 批量导入SAI开项管理列表
      */

+ 33 - 0
master/src/main/java/com/ruoyi/project/production/controller/vo/SaiApplyQueryVO.java

@@ -24,6 +24,15 @@ public class SaiApplyQueryVO extends BaseEntity {
     /** 主键 */
     private Long saiApplyId;
 
+    /** tab,1待处理,2我的,3总数据 */
+    private int tab;
+
+    /** 当前登录用户id */
+    private long currentUser;
+
+    /** 当前登录用户是否为特殊角色(供SAI功能展示使用) */
+    private boolean isSpecialRole;
+
     /** 删除状态 */
     private String delFlag;
 
@@ -162,6 +171,30 @@ public class SaiApplyQueryVO extends BaseEntity {
     /** 备注(执行阶段) */
     private String remarksExecute;
 
+    public boolean isSpecialRole() {
+        return isSpecialRole;
+    }
+
+    public void setSpecialRole(boolean specialRole) {
+        isSpecialRole = specialRole;
+    }
+
+    public long getCurrentUser() {
+        return currentUser;
+    }
+
+    public void setCurrentUser(long currentUser) {
+        this.currentUser = currentUser;
+    }
+
+    public int getTab() {
+        return tab;
+    }
+
+    public void setTab(int tab) {
+        this.tab = tab;
+    }
+
     public String getRemarksAssess() {
         return remarksAssess;
     }

+ 45 - 18
master/src/main/java/com/ruoyi/project/production/service/impl/TSaiApplyServiceImpl.java

@@ -1,10 +1,14 @@
 package com.ruoyi.project.production.service.impl;
 
+import com.github.pagehelper.Page;
+import com.github.pagehelper.PageHelper;
 import com.ruoyi.common.utils.DateUtils;
 import com.ruoyi.common.utils.ServletUtils;
 import com.ruoyi.common.utils.spring.SpringUtils;
 import com.ruoyi.framework.security.LoginUser;
 import com.ruoyi.framework.security.service.TokenService;
+import com.ruoyi.framework.web.page.PageDomain;
+import com.ruoyi.framework.web.page.TableSupport;
 import com.ruoyi.project.production.controller.vo.SaiApplyQueryVO;
 import com.ruoyi.project.production.domain.TSaiApply;
 import com.ruoyi.project.production.mapper.TSaiApplyMapper;
@@ -20,6 +24,7 @@ import com.ruoyi.project.system.service.ISysUserService;
 import org.springframework.stereotype.Service;
 
 import javax.annotation.Resource;
+import java.util.ArrayList;
 import java.util.List;
 import java.util.concurrent.CountDownLatch;
 import java.util.concurrent.ExecutorService;
@@ -77,13 +82,38 @@ public class TSaiApplyServiceImpl implements ITSaiApplyService
     @Override
     public List<TSaiApply> selectTSaiApplyList(SaiApplyQueryVO tSaiApply)
     {
-        List<TSaiApply> tSaiApplies = tSaiApplyMapper.selectTSaiApplyList(tSaiApply);
-//        List<SysUser> userList = userService.selectUserList(new SysUser());
-//        Map<Long, String> nameMap = new HashMap<Long, String>();
-//        for (SysUser sysUser : userList) {
-//            nameMap.put(sysUser.getUserId(), sysUser.getNickName());
+//        // 当前登录用户userId
+//        LoginUser loginUser = SpringUtils.getBean(TokenService.class).getLoginUser(ServletUtils.getRequest());
+//        Long userId = loginUser.getUser().getUserId();
+//
+//        List<TSaiApply> result = tSaiApplyMapper.selectTSaiApplyList(tSaiApply);
+//
+//        List<TSaiApply> tSaiApplies = new ArrayList<>();
+//
+//        for (TSaiApply saiApply : result) {
+//            // 待处理:当前用户为流程当前处理人(之一),申请流程未结束
+//            if (tSaiApply.getTab() == 1) {
+//                if (saiApply.getHandler().indexOf(userId.toString()) != -1 && saiApply.getApplyStatus() != 4 && saiApply.getApplyStatus() != 5) {
+//                    tSaiApplies.add(saiApply);
+//                }
+//            }
+//            // 我的:当前用户为登记人、评估人、整改负责人或验证人(之一)
+//            else if (tSaiApply.getTab() == 2) {
+//                if ((saiApply.getApplicant() != null && saiApply.getApplicant().indexOf(userId.toString()) != -1)
+//                     || (saiApply.getAssessor() != null && saiApply.getAssessor().indexOf(userId.toString()) != -1)
+//                     || (saiApply.getExecutor() != null && saiApply.getExecutor().indexOf(userId.toString()) != -1)
+//                     || (saiApply.getInspectors() != null && saiApply.getInspectors().indexOf(userId.toString()) != -1)) {
+//                    tSaiApplies.add(saiApply);
+//                }
+//            }
+//            // 总数据
+//            else if (tSaiApply.getTab() == 3) {
+//                tSaiApplies.add(saiApply);
+//            }
 //        }
 
+        List<TSaiApply> tSaiApplies = tSaiApplyMapper.selectTSaiApplyList(tSaiApply);
+
         List<SysDictData> staffUnitDict = iSysDictTypeService.selectDictDataByType("STAFF_UNIT");
 
         ExecutorService executorService = Executors.newFixedThreadPool(20);
@@ -104,7 +134,6 @@ public class TSaiApplyServiceImpl implements ITSaiApplyService
                         }
                     }
                     if (applicant != null) {
-//                saiApply.setApplicantName(sysUserMapper.selectUserById(Long.parseLong(applicant)).getNickName());
                         SysUser sysUser = sysUserMapper.selectNickNameById(Long.parseLong(applicant));
                         if (sysUser!=null) {
                             String applicantName = sysUser.getNickName();
@@ -118,7 +147,6 @@ public class TSaiApplyServiceImpl implements ITSaiApplyService
                             String[] split = handler.split(",");
                             StringBuilder handlerName = new StringBuilder();
                             for (int i = 0; i < split.length; i++) {
-//                        handlerName += sysUserMapper.selectUserById(Long.parseLong(split[i])).getNickName();
                                 SysUser sysUser = sysUserMapper.selectNickNameById(Long.parseLong(split[i]));
                                 if (sysUser!=null) {
                                     String name = sysUser.getNickName();
@@ -132,7 +160,6 @@ public class TSaiApplyServiceImpl implements ITSaiApplyService
                             }
                             saiApply.setHandlerName(handlerName.toString());
                         } else {
-//                    saiApply.setHandlerName(sysUserMapper.selectUserById(Long.parseLong(handler)).getNickName());
                             SysUser sysUser = sysUserMapper.selectNickNameById(Long.parseLong(handler));
                             if (sysUser!=null) {
                                 String handlerName = sysUser.getNickName();
@@ -143,7 +170,6 @@ public class TSaiApplyServiceImpl implements ITSaiApplyService
                         }
                     }
                     if (executor != null) {
-//                saiApply.setExecutorName(sysUserMapper.selectUserById(Long.parseLong(executor)).getNickName());
                         SysUser sysUser = sysUserMapper.selectNickNameById(Long.parseLong(executor));
                         if (sysUser!=null) {
                             String executorName = sysUser.getNickName();
@@ -164,15 +190,16 @@ public class TSaiApplyServiceImpl implements ITSaiApplyService
         }
         executorService.shutdown();
 
-        boolean specialRole = this.isSpecialRole();
-        if (specialRole) {  // 当前登录用户是特殊角色
-            for (TSaiApply saiApply : tSaiApplies) {
-                long applyStatus = saiApply.getApplyStatus();
-                if (Long.toString(applyStatus).equals("5")) {   // 申请状态为“已取消”的数据
-                    tSaiApplies.remove(saiApply);   // 从列表中移除
-                }
-            }
-        }
+//        boolean specialRole = this.isSpecialRole();
+//        if (specialRole) {  // 当前登录用户是特殊角色
+//            for (TSaiApply saiApply : tSaiApplies) {
+//                long applyStatus = saiApply.getApplyStatus();
+//                if (Long.toString(applyStatus).equals("5")) {   // 申请状态为“已取消”的数据
+//                    tSaiApplies.remove(saiApply);   // 从列表中移除
+//                }
+//            }
+//        }
+
         return tSaiApplies;
     }
 

+ 14 - 0
master/src/main/resources/mybatis/production/TSaiApplyMapper.xml

@@ -59,6 +59,20 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             resultMap="TSaiApplyResult">
         <include refid="selectTSaiApplyVo"/>
         <where>
+            <if test="tab == 1">
+                and handler like concat(concat('%', #{currentUser}), '%')
+                and apply_status != 4
+                and apply_status != 5
+            </if>
+            <if test="tab == 2">
+                and (handler like concat(concat('%', #{currentUser}), '%')
+                or assessor like concat(concat('%', #{currentUser}), '%')
+                or executor like concat(concat('%', #{currentUser}), '%')
+                or inspectors like concat(concat('%', #{currentUser}), '%'))
+            </if>
+            <if test="isSpecialRole == true">
+                and apply_status != 5
+            </if>
             <if test="applyDateStart != null ">and apply_date <![CDATA[>=]]> #{applyDateStart}</if>
             <if test="applyDateEnd != null">and apply_date <![CDATA[<=]]>#{applyDateEnd}</if>
             <if test="estimateFinishDateStart != null ">and estimate_finish_date <![CDATA[>=]]> #{estimateFinishDateStart}</if>

+ 1 - 0
ui/src/views/production/apply/all/index.vue

@@ -1337,6 +1337,7 @@ export default {
     /** 查询SAI开项管理列表 */
     getList() {
       this.loading = true;
+      this.queryParams.tab = 3;
       listApply(this.queryParams).then(response => {
         this.applyList = response.rows;
         this.total = response.total;

+ 13 - 11
ui/src/views/production/apply/mine/index.vue

@@ -1342,18 +1342,20 @@
           if (staff != null) {
             this.loginStaffInfo = response.data;
           }
+          this.queryParams.tab = 2;
           listApply(this.queryParams).then(response => {
-            let rows = response.rows;
-            this.applyList = [];
-            for (let i = 0; i < rows.length; i++) {
-              // 当前用户为登记人、评估人、整改负责人或验证人(之一)
-              if ((rows[i].applicant != null && rows[i].applicant.indexOf(this.loginStaffInfo.userId) != -1)
-                || (rows[i].assessor != null && rows[i].assessor.indexOf(this.loginStaffInfo.userId) != -1)
-                || (rows[i].executor != null && rows[i].executor.indexOf(this.loginStaffInfo.userId) != -1)
-                || (rows[i].inspectors != null && rows[i].inspectors.indexOf(this.loginStaffInfo.userId) != -1)) {
-                this.applyList.push(rows[i]);
-              }
-            }
+            // let rows = response.rows;
+            // this.applyList = [];
+            // for (let i = 0; i < rows.length; i++) {
+            //   // 当前用户为登记人、评估人、整改负责人或验证人(之一)
+            //   if ((rows[i].applicant != null && rows[i].applicant.indexOf(this.loginStaffInfo.userId) != -1)
+            //     || (rows[i].assessor != null && rows[i].assessor.indexOf(this.loginStaffInfo.userId) != -1)
+            //     || (rows[i].executor != null && rows[i].executor.indexOf(this.loginStaffInfo.userId) != -1)
+            //     || (rows[i].inspectors != null && rows[i].inspectors.indexOf(this.loginStaffInfo.userId) != -1)) {
+            //     this.applyList.push(rows[i]);
+            //   }
+            // }
+            this.applyList = response.rows;
             this.total = response.total;
             this.loading = false;
           });

+ 10 - 8
ui/src/views/production/apply/pending/index.vue

@@ -1342,15 +1342,17 @@
           if (staff != null) {
             this.loginStaffInfo = response.data;
           }
+          this.queryParams.tab = 1;
           listApply(this.queryParams).then(response => {
-            let rows = response.rows;
-            this.applyList = [];
-            for (let i = 0; i < rows.length; i++) {
-              // 当前用户为流程当前处理人(之一),申请流程未结束
-              if (rows[i].handler.indexOf(this.loginStaffInfo.userId) != -1 && rows[i].applyStatus != 4 && rows[i].applyStatus != 5) {
-                this.applyList.push(rows[i]);
-              }
-            }
+            // let rows = response.rows;
+            // this.applyList = [];
+            // for (let i = 0; i < rows.length; i++) {
+            //   // 当前用户为流程当前处理人(之一),申请流程未结束
+            //   if (rows[i].handler.indexOf(this.loginStaffInfo.userId) != -1 && rows[i].applyStatus != 4 && rows[i].applyStatus != 5) {
+            //     this.applyList.push(rows[i]);
+            //   }
+            // }
+            this.applyList = response.rows;
             this.total = response.total;
             this.loading = false;
           });