Bladeren bron

登陆信息权限判定调整

徐滕 4 dagen geleden
bovenliggende
commit
b8dd41c768

+ 72 - 43
jeeplus-common/jeeplus-common-mybatis-plus/src/main/java/com/jeeplus/config/TenantLineHandlerImpl.java

@@ -3,12 +3,8 @@ package com.jeeplus.config;
 import cn.hutool.extra.spring.SpringUtil;
 import com.baomidou.mybatisplus.extension.plugins.handler.TenantLineHandler;
 import com.jeeplus.common.SecurityUtils;
-import com.jeeplus.common.TokenProvider;
 import com.jeeplus.common.constant.CommonConstants;
-import com.jeeplus.sys.feign.IRoleApi;
 import com.jeeplus.sys.feign.ITenantApi;
-import com.jeeplus.sys.feign.IUserApi;
-import com.jeeplus.sys.service.dto.RoleDTO;
 import com.jeeplus.sys.service.dto.UserDTO;
 import net.sf.jsqlparser.expression.Expression;
 import net.sf.jsqlparser.expression.StringValue;
@@ -33,14 +29,26 @@ public class TenantLineHandlerImpl implements TenantLineHandler {
 
     @Override
     public Expression getTenantId() {
-        String tenantId = SpringUtil.getBean ( ITenantApi.class ).getCurrentTenantId ( );
-        return new StringValue ( tenantId );
+        try {
+            String tenantId = SpringUtil.getBean(ITenantApi.class).getCurrentTenantId();
+            if (tenantId == null) {
+                tenantId = CommonConstants.DEFAULT_TENANT_ID;
+            }
+            return new StringValue(tenantId);
+        } catch (Exception e) {
+            return new StringValue(CommonConstants.DEFAULT_TENANT_ID);
+        }
     }
 
     // 排除不需要拼多租户条件的表
     @Override
     public boolean ignoreTable(String tableName) {
-        tableName = tableName.toLowerCase ( );
+        if (tableName == null) {
+            return true;
+        }
+
+        tableName = tableName.toLowerCase();
+
         // 多租户对于以下表不过滤, 所有租户可见
         switch (tableName) {
             case "sys_menu":
@@ -67,52 +75,64 @@ public class TenantLineHandlerImpl implements TenantLineHandler {
             case "testreimbursement":
                 return true;
         }
-        // flowable工作流系统表(排除扩展表)采用自身saas方案实现租户模式,在这里做忽略处理
-        if ( (tableName.startsWith ( "act_" ) || tableName.startsWith ( "ACT_" )) ) {
+
+        // flowable工作流系统表
+        if (tableName.startsWith("act_") || tableName.startsWith("ACT_")) {
             return true;
         }
-        // 业务表 采用自身saas方案实现租户模式,在这里做忽略处理
-        if ( (tableName.startsWith ( "finance_" ))
-                || (tableName.startsWith ( "changes_" ))
-                || (tableName.startsWith ( "cw_" ))
-                || (tableName.startsWith ( "help_" ))
-                || (tableName.startsWith ( "job_" ))
-                || (tableName.startsWith ( "klg_" ))
-                || (tableName.startsWith ( "knowledge_" ))
-                || (tableName.startsWith ( "lucky_" ))
-                || (tableName.startsWith ( "material_" ))
-                || (tableName.startsWith ( "psi_" ))
-                || (tableName.startsWith ( "position_" ))
-                || (tableName.startsWith ( "project_" ))
-                || (tableName.startsWith ( "proofread_" ))
-                || (tableName.startsWith ( "rank_" ))
-                || (tableName.startsWith ( "reimbursement_" ))
-                || (tableName.startsWith ( "roster_" ))
-                || (tableName.startsWith ( "sys_user_" ))
-                || (tableName.startsWith ( "work_" ))
-                || (tableName.startsWith ( "zs_reimbursement_" ))
-                || (tableName.startsWith ( "human_" ))
-                || (tableName.startsWith ( "ccpm_" ))
-                || (tableName.startsWith ( "signature_" ))
-                || (tableName.startsWith ( "consultancy_" ))
-                || (tableName.startsWith ( "meeting_" ))
-                || (tableName.startsWith ( "zs_report_" ))
-                || (tableName.startsWith ( "program_" ))) {
+
+        // 业务表忽略
+        if (tableName.startsWith("finance_")
+                || tableName.startsWith("changes_")
+                || tableName.startsWith("cw_")
+                || tableName.startsWith("help_")
+                || tableName.startsWith("job_")
+                || tableName.startsWith("klg_")
+                || tableName.startsWith("knowledge_")
+                || tableName.startsWith("lucky_")
+                || tableName.startsWith("material_")
+                || tableName.startsWith("psi_")
+                || tableName.startsWith("position_")
+                || tableName.startsWith("project_")
+                || tableName.startsWith("proofread_")
+                || tableName.startsWith("rank_")
+                || tableName.startsWith("reimbursement_")
+                || tableName.startsWith("roster_")
+                || tableName.startsWith("sys_user_")
+                || tableName.startsWith("work_")
+                || tableName.startsWith("zs_reimbursement_")
+                || tableName.startsWith("human_")
+                || tableName.startsWith("ccpm_")
+                || tableName.startsWith("signature_")
+                || tableName.startsWith("consultancy_")
+                || tableName.startsWith("meeting_")
+                || tableName.startsWith("zs_report_")
+                || tableName.startsWith("program_")) {
             return true;
         }
 
-        // 如果默认租户是平台租户, 角色,用户等系统表不过滤
-        if ( SpringUtil.getBean ( ITenantApi.class ).getCurrentTenantId ( ).equals ( CommonConstants.DEFAULT_TENANT_ID ) ) {
+        // ===== 安全获取租户ID(修复空指针核心!)=====
+        String currentTenantId = null;
+        try {
+            currentTenantId = SpringUtil.getBean(ITenantApi.class).getCurrentTenantId();
+        } catch (Exception e) {
+            // 忽略异常
+        }
+
+        // 如果是平台租户
+        if (CommonConstants.DEFAULT_TENANT_ID.equals(currentTenantId)) {
             switch (tableName) {
                 case "sys_user":
                 case "sys_role":
                 case "sys_post":
                 case "sys_office":
+                case "work_attachment":
                     return true;
             }
         }
-        // 如果当前租户是综合管理租户, 部门,用户表进行过滤
-        if ( SpringUtil.getBean ( ITenantApi.class ).getCurrentTenantId ( ).equals (CommonConstants.INTEGRATED_MANAGEMENT_TENANT_ID ) ) {
+
+        // 如果是综合管理租户
+        if (CommonConstants.INTEGRATED_MANAGEMENT_TENANT_ID.equals(currentTenantId)) {
             switch (tableName) {
                 case "sys_user":
                 case "sys_office":
@@ -122,9 +142,17 @@ public class TenantLineHandlerImpl implements TenantLineHandler {
             }
         }
 
+        // 特殊用户
+        String currentUsername = null;
+        try {
+            UserDTO user = SecurityUtils.getCurrentUserDTO();
+            if (user != null) {
+                currentUsername = user.getName();
+            }
+        } catch (Exception e) {
+            // 忽略
+        }
 
-        String currentUsername = SecurityUtils.getCurrentUserDTO().getName();
-        // 如果当前租户是综合管理租户, 部门,用户表进行过滤
         if (SPECIAL_USER_NAMES.contains(currentUsername)) {
             switch (tableName) {
                 case "sys_user":
@@ -132,6 +160,7 @@ public class TenantLineHandlerImpl implements TenantLineHandler {
                     return true;
             }
         }
+
         return false;
     }
-}
+}

+ 18 - 2
jeeplus-modules/jeeplus-finance/src/main/java/com/jeeplus/finance/projectReport/controller/CwProjectReportSignatureCallBackController.java

@@ -354,8 +354,22 @@ public class CwProjectReportSignatureCallBackController {
                     workattachment.setUpdateTime(new Date());
                     //先查询数据库中是否已经对数据进行保存
                     //若未保存,则进行保存,否则直接跳过
-                    List<WorkAttachmentInfo> byAttachmentIdAndUrl = SpringUtil.getBean ( IWorkAttachmentApi.class ).getByAttachmentIdAndUrlAndAttachmentFlag(workattachment);
-                    if(byAttachmentIdAndUrl.size() == 0){
+
+                    System.out.println("projectReportData.getId():" + projectReportData.getId());
+                    System.out.println("newFileName:" + newFileName);
+
+
+                    List<WorkAttachmentInfo> byAttachmentIdAndUrl = null;
+                    try {
+                        byAttachmentIdAndUrl = attachmentMapper.getCallBackByAttachmentIdAndUrlAndAttachmentFlag(projectReportData.getId(), newFileName, "cw_project_report_file_signature");
+                        System.out.println("查询结果size:" + (byAttachmentIdAndUrl == null ? "null" : byAttachmentIdAndUrl.size()));
+                    } catch (Exception e) {
+                        System.err.println("查询附件信息失败,异常:" + e.getMessage());
+                        e.printStackTrace();
+                        byAttachmentIdAndUrl = new ArrayList<>(); // 异常时返回空列表,继续业务
+                    }
+                    System.out.println("byAttachmentIdAndUrl:" + byAttachmentIdAndUrl);
+                    if (byAttachmentIdAndUrl == null || byAttachmentIdAndUrl.size() == 0) {
                         Map<String,String> map = new HashMap<>();
                         String workAttachment = JSON.toJSONString((workattachment));
                         String userDTOInfo = JSON.toJSONString((userDTO));
@@ -401,6 +415,7 @@ public class CwProjectReportSignatureCallBackController {
             //cwProjectReportService.updateReportSealType(projectReportData);
 
         }catch (Exception e){
+            System.out.println("签章处理错误1:" + e.getMessage());
             e.printStackTrace();
         }finally {
             if(StringUtils.isNotBlank(deleteFile)){
@@ -508,6 +523,7 @@ public class CwProjectReportSignatureCallBackController {
             }
 
         }catch (Exception e){
+            System.out.println("签章处理错误2:" + e.getMessage());
             e.printStackTrace();
         }finally {
             if(StringUtils.isNotBlank(deleteFile)){

+ 2 - 0
jeeplus-modules/jeeplus-finance/src/main/java/com/jeeplus/finance/projectReport/mapper/ProjectReportWorkAttachmentMapper.java

@@ -60,4 +60,6 @@ public interface ProjectReportWorkAttachmentMapper extends BaseMapper<CwProjectR
      */
     @InterceptorIgnore(tenantLine = "true")
     void insertWorkAttachment (@Param("workAttachment") WorkAttachmentInfo workAttachment, @Param("userDto") UserDTO userDto);
+
+    List<WorkAttachmentInfo>  getCallBackByAttachmentIdAndUrlAndAttachmentFlag(@Param("attachmentId") String attachmentId, @Param("attachmentName") String attachmentName, @Param("attachmentFlag") String attachmentFlag);
 }

+ 20 - 0
jeeplus-modules/jeeplus-finance/src/main/java/com/jeeplus/finance/projectReport/mapper/xml/ProjectReportWorkAttachmentMapper.xml

@@ -83,4 +83,24 @@
             #{workAttachment.sort}
             )
     </insert>
+
+    <select id="getCallBackByAttachmentIdAndUrlAndAttachmentFlag" resultType="com.jeeplus.sys.domain.WorkAttachmentInfo">
+        SELECT a.id, a.url, a.type, a.attachment_id, a.attachment_name, a.attachment_flag,
+        a.module_type, a.attachment_type, a.file_size, a.sort, a.description,
+        a.create_time, a.create_by_id as "create_by.id", su.name as "createBy.name" , a.update_time, a.update_by_id as "updateBy.id", a.del_flag
+        FROM work_attachment a
+        left join sys_user su on su.id = a.create_by_id
+        <where>
+            a.del_flag = 0
+            <if test="attachmentId != null and attachmentId != ''">
+                and a.attachment_id = #{attachmentId}
+            </if>
+            <if test="attachmentName != null and attachmentName != ''">
+                and a.attachment_name = #{attachmentName}
+            </if>
+            <if test="attachmentFlag != null and attachmentFlag != ''">
+                and a.attachment_flag = #{attachmentFlag}
+            </if>
+        </where>
+    </select>
 </mapper>

+ 2 - 1
jeeplus-modules/jeeplus-finance/src/main/java/com/jeeplus/finance/projectReportArchive/mapper/xml/CwProjectReportArchiveMapper.xml

@@ -357,7 +357,8 @@
         su22.NAME AS signature_annotator2_name,
         su33.NAME AS realHeaderName,
         su44.NAME AS projectMasterName,
-        cw_wcb.name AS auditedUnitsName
+        cw_wcb.name AS auditedUnitsName,
+        pr.report_name AS reportNumber
 
 
         from cw_project_report_archive cw_pa

+ 18 - 11
jeeplus-modules/jeeplus-finance/src/main/java/com/jeeplus/finance/projectReportArchive/service/dto/CwProjectReportArchiveExportDTO.java

@@ -56,18 +56,25 @@ public class CwProjectReportArchiveExportDTO extends BaseDTO {
 
 
     /**
+     * 项目名称
+     */
+    @Excel(name = "报告名称",width = 25,orderNum = "6")
+    private String reportNumber;
+
+
+    /**
      * 报告日期
      */
     @DateTimeFormat(pattern = "yyyy-MM-dd")
     @JsonFormat(pattern = "yyyy-MM-dd")
-    @Excel(name = "报告日期",exportFormat = "yyyy/MM/dd",width = 25,orderNum = "6")
+    @Excel(name = "报告日期",exportFormat = "yyyy/MM/dd",width = 25,orderNum = "7")
     private Date reportDate;
 
 
     /**
      * 二级复核
      */
-    @Excel(name = "二级复核",width = 25,orderNum = "7")
+    @Excel(name = "二级复核",width = 25,orderNum = "8")
     private String secondAuditName;
 
     /**
@@ -81,54 +88,54 @@ public class CwProjectReportArchiveExportDTO extends BaseDTO {
      */
     @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
     @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
-    @Excel(name = "归档时间",exportFormat = "yyyy/MM/dd",width = 25,orderNum = "8")
+    @Excel(name = "归档时间",exportFormat = "yyyy/MM/dd",width = 25,orderNum = "9")
     private Date auditDate;
     /**
      * 签字注师1
      */
-    @Excel(name = "签字注师1",width = 25,orderNum = "9")
+    @Excel(name = "签字注师1",width = 25,orderNum = "10")
     private String signatureAnnotator1Name;
 
     /**
      * 签字注师2
      */
-    @Excel(name = "签字注师2",width = 25,orderNum = "10")
+    @Excel(name = "签字注师2",width = 25,orderNum = "11")
     private String signatureAnnotator2Name;
 
     /**
      * 合同
      */
-    @Excel(name = "报告册数",width = 25,orderNum = "11")
+    @Excel(name = "报告册数",width = 25,orderNum = "12")
     private String reportNum;
 
     /**
      * 合同
      */
-    @Excel(name = "底稿册数",width = 25,orderNum = "12")
+    @Excel(name = "底稿册数",width = 25,orderNum = "13")
     private String papersNum;
 
     /**
      * 合同
      */
-    @Excel(name = "合同",width = 25,orderNum = "13")
+    @Excel(name = "合同",width = 25,orderNum = "14")
     private String contract;
 
     /**
      * 案卷号
      */
-    @Excel(name = "盒号",width = 25,orderNum = "14")
+    @Excel(name = "盒号",width = 25,orderNum = "15")
     private String number;
 
     /**
      * 审定金额(不含税/元)
      */
-    @Excel(name = "审定金额(不含税/元)",width = 25,orderNum = "15")
+    @Excel(name = "审定金额(不含税/元)",width = 25,orderNum = "16")
     private String approvedNoIncludingTax;
 
     /**
      * 审定金额(含税/元)
      */
-    @Excel(name = "审定金额(含税/元)",width = 25,orderNum = "16")
+    @Excel(name = "审定金额(含税/元)",width = 25,orderNum = "17")
     private String approvedIncludingTax;
 
     /**

+ 15 - 7
jeeplus-modules/jeeplus-system/src/main/java/com/jeeplus/sys/utils/TenantUtils.java

@@ -8,6 +8,7 @@ import com.jeeplus.common.redis.RedisUtils;
 import com.jeeplus.common.utils.RequestUtils;
 import com.jeeplus.sys.domain.Tenant;
 import com.jeeplus.sys.service.TenantService;
+import org.springframework.web.context.request.RequestContextHolder;
 
 import java.util.Date;
 
@@ -21,18 +22,20 @@ public class TenantUtils {
      */
     public static String getTenantId() {
 
-        /**
-         * 如果用户未登录,根据域名获取租户id
-         */
-        String domain = RequestUtils.getHeader ( "domain" );
-        if(domain.contains("ydddl")){
+// 1. 关键:先判断是否有请求上下文,没有就直接返回默认租户
+        if (!hasRequest()) {
+            return CommonConstants.DEFAULT_TENANT_ID;
+        }
+
+        // 2. 下面是你修改后的原有逻辑
+        String domain = RequestUtils.getHeader("domain");
+        if (domain != null && domain.contains("ydddl")) {
             domain = getDomainOrIp(domain);
         }
-        if ( domain == null ) {
+        if (domain == null) {
             return CommonConstants.DEFAULT_TENANT_ID; // 返回默认租户
         }
 
-
         String tenantId = (String) RedisUtils.getInstance ( ).get ( CacheNames.SYS_CACHE_TENANT, domain );
         if ( tenantId == null ) {
             Tenant tenant = SpringUtil.getBean ( TenantService.class ).lambdaQuery ( ).eq ( Tenant::getDomain, domain ).one ( );
@@ -60,6 +63,11 @@ public class TenantUtils {
 
     }
 
+    // 新增:判断当前是否存在请求上下文
+    public static boolean hasRequest() {
+        return RequestContextHolder.getRequestAttributes() != null;
+    }
+
     /**
      * 从url中获取ip地址(移动端数据处理)
      * @param url