From bb1487efec7f9b55db0af2535dfa5649d95089b7 Mon Sep 17 00:00:00 2001
From: luofl <1442745593@qq.com>
Date: 星期二, 18 三月 2025 10:13:11 +0800
Subject: [PATCH] bug修改

---
 springcloud_k8s_panzhihuazhihuishequ/service_sangeshenbian/src/main/java/com/panzhihua/sangeshenbian/service/impl/ComplaintServiceImpl.java |  147 ++++++++++++++++++++++++++++---------------------
 1 files changed, 84 insertions(+), 63 deletions(-)

diff --git a/springcloud_k8s_panzhihuazhihuishequ/service_sangeshenbian/src/main/java/com/panzhihua/sangeshenbian/service/impl/ComplaintServiceImpl.java b/springcloud_k8s_panzhihuazhihuishequ/service_sangeshenbian/src/main/java/com/panzhihua/sangeshenbian/service/impl/ComplaintServiceImpl.java
index 4e450a7..ffa5d1c 100644
--- a/springcloud_k8s_panzhihuazhihuishequ/service_sangeshenbian/src/main/java/com/panzhihua/sangeshenbian/service/impl/ComplaintServiceImpl.java
+++ b/springcloud_k8s_panzhihuazhihuishequ/service_sangeshenbian/src/main/java/com/panzhihua/sangeshenbian/service/impl/ComplaintServiceImpl.java
@@ -2,6 +2,7 @@
 
 import cn.hutool.core.bean.BeanUtil;
 import cn.hutool.core.collection.CollUtil;
+import cn.hutool.core.collection.CollectionUtil;
 import cn.idev.excel.EasyExcel;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
@@ -37,7 +38,9 @@
 import com.panzhihua.sangeshenbian.model.vo.ComplaintVO;
 import com.panzhihua.sangeshenbian.service.ISystemUserService;
 import com.panzhihua.sangeshenbian.utils.FileUtil;
+import com.panzhihua.sangeshenbian.warpper.IdentityInformationVO;
 import com.panzhihua.sangeshenbian.warpper.MgtComplaintQuery;
+import com.panzhihua.sangeshenbian.warpper.PermissionsVO;
 import lombok.RequiredArgsConstructor;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.context.annotation.Lazy;
@@ -82,6 +85,7 @@
     private final IComplaintCommentService complaintCommentService;
     private final HttpServletResponse response;
     private final IPartyMemberService partyMemberService;
+    private final IdentityInformationService identityInformationService;
     private final RedisUtils redisUtils;
 
     @Override
@@ -110,8 +114,10 @@
         complaint.setSerialNumber(serialNumber);
         Optional<SystemUser> systemUserOpt = systemUserService.getSystemUserAdminByPhone(loginUserInfoVO.getPhone());
         Integer accountLevel = 5;
-        //获取当前身份,1=党员,2=管理员
-        Integer identity = (Integer) redisUtils.get("identity:" + loginUserInfoVO.getPhone());
+        //获取当前身份
+        IdentityInformationVO identityInformationVO = identityInformationService.getIdentityInformationVO(loginUserInfoVO);
+        //1=党员,2=管理员
+        Integer identity = identityInformationVO.getIdentity();
         if (systemUserOpt.isPresent() && null != identity && identity == 2) {
             SystemUser systemUser = systemUserOpt.get();
             accountLevel = systemUser.getAccountLevel();
@@ -270,7 +276,7 @@
             }
         }
         //有审核数据,且正在办理
-        if(null != one && (vo.getStatus() == 0 || vo.getStatus() == 1 || vo.getStatus() == 2)){
+        if(null != one && (vo.getStatus() == 0 || vo.getStatus() == 1 || vo.getStatus() == 2 || vo.getStatus() == 6)){
             //区分是上报数据还是下派数据
             if(one.getAuditType() == 2){
                 //判断当前审核状态
@@ -286,48 +292,6 @@
                         }
                     }
                 }else{
-                    //审核状态为待审核,需要授权审核按钮
-                    if((one.getAuditStatus() == 5 || one.getAuditStatus() == 7) && systemUserByPhone.isPresent()){
-                        SystemUser systemUser = systemUserByPhone.get();
-                        String targetId = "";
-                        Integer accountLevel = 5;
-                        //获取当前身份,1=党员,2=管理员
-                        Integer identity = (Integer) redisUtils.get("identity:" + systemUser.getPhone());
-                        if(2 == identity){
-                            accountLevel = systemUser.getAccountLevel();
-                            switch (accountLevel) {
-                                case 1:
-                                    //市级
-                                    targetId = "510400";
-                                    break;
-                                case 2:
-                                    //区县级
-                                    targetId = systemUser.getDistrictsCode();
-                                    break;
-                                case 3:
-                                    //街道
-                                    targetId = systemUser.getStreetId().toString();
-                                    break;
-                                case 4:
-                                    //社区
-                                    targetId = systemUser.getCommunityId().toString();
-                                    break;
-                                case 5:
-                                    //党员
-                                    PartyMember partyMember = partyMemberService.getPartyMemberByPhone(systemUser.getPhone());
-                                    targetId = partyMember.getId().toString();
-                                    break;
-                            }
-    
-                            ComplaintAuditRecord one2 = complaintAuditRecordService.getOne(new LambdaQueryWrapper<ComplaintAuditRecord>().eq(ComplaintAuditRecord::getComplaintId, vo.getId())
-                                    .eq(ComplaintAuditRecord::getLatestFlag, 1));
-                            Integer isAdmin = systemUserByPhone.get().getIsAdmin();
-                            if(one2.getReportType().equals(accountLevel) && one2.getSuperiorId().toString().equals(targetId) && 1 == isAdmin){
-                                vo.setAuditButtonStatus(0);
-                            }
-                        }
-                    }
-                    
                     //没有审核通过,则需要查询上一条审核通过的数据,如果没有则给到添加诉求的人
                     ComplaintAuditRecord one1 = complaintAuditRecordService.getOne(new LambdaQueryWrapper<ComplaintAuditRecord>().eq(ComplaintAuditRecord::getComplaintId, vo.getId())
                             .eq(ComplaintAuditRecord::getAuditType, 2).eq(ComplaintAuditRecord::getAuditStatus, 1).orderByDesc(ComplaintAuditRecord::getSort).last(" limit 0, 1"));
@@ -415,6 +379,50 @@
                 }
             }
         }
+
+        //有审核数据,且为审核中
+        //审核状态为待审核,需要授权审核按钮
+        if(null != one && (vo.getStatus() == 5 || vo.getStatus() == 7) && systemUserByPhone.isPresent()){
+            SystemUser systemUser = systemUserByPhone.get();
+            String targetId = "";
+            Integer accountLevel = 5;
+            //获取当前身份,1=党员,2=管理员
+            Integer identity = (Integer) redisUtils.get("identity:" + systemUser.getPhone());
+            if(2 == identity){
+                accountLevel = systemUser.getAccountLevel();
+                switch (accountLevel) {
+                    case 1:
+                        //市级
+                        targetId = "510400";
+                        break;
+                    case 2:
+                        //区县级
+                        targetId = systemUser.getDistrictsCode();
+                        break;
+                    case 3:
+                        //街道
+                        targetId = systemUser.getStreetId().toString();
+                        break;
+                    case 4:
+                        //社区
+                        targetId = systemUser.getCommunityId().toString();
+                        break;
+                    case 5:
+                        //党员
+                        PartyMember partyMember = partyMemberService.getPartyMemberByPhone(systemUser.getPhone());
+                        targetId = partyMember.getId().toString();
+                        break;
+                }
+
+                ComplaintAuditRecord one2 = complaintAuditRecordService.getOne(new LambdaQueryWrapper<ComplaintAuditRecord>().eq(ComplaintAuditRecord::getComplaintId, vo.getId())
+                        .eq(ComplaintAuditRecord::getLatestFlag, 1));
+                Integer isAdmin = systemUserByPhone.get().getIsAdmin();
+                if(one2.getReportType().equals(accountLevel) && one2.getSuperiorId().toString().equals(targetId) && 1 == isAdmin){
+                    vo.setAuditButtonStatus(0);
+                }
+            }
+        }
+
         
         //状态为已办结,判断评价按钮
         int count = complaintCommentService.count(new LambdaQueryWrapper<ComplaintComment>().eq(ComplaintComment::getComplaintId, vo.getId()).eq(ComplaintComment::getDelFlag, 0));
@@ -489,16 +497,16 @@
         List<ComplaintProgress> list = complaintProgressService.lambdaQuery().eq(ComplaintProgress::getComplaintId, id)
                 .orderByAsc(ComplaintProgress::getCreateTime).list();
         detail.setComplaintProgresses(list);
-        detail.setAuditButtonStatus(1);
-        detail.setEvaluateButtonStatus(1);
-        if((detail.getStatus() == 5 || detail.getStatus() == 7) && systemUserByPhone.isPresent()){
-            ComplaintAuditRecord one = complaintAuditRecordService.getOne(new LambdaQueryWrapper<ComplaintAuditRecord>().eq(ComplaintAuditRecord::getComplaintId, detail.getId())
-                    .eq(ComplaintAuditRecord::getLatestFlag, 1));
-            Integer isAdmin = systemUserByPhone.get().getIsAdmin();
-            if(one.getReportType().equals(accountLevel) && one.getSuperiorId().toString().equals(targetId) && 1 == isAdmin){
-                detail.setAuditButtonStatus(0);
-            }
-        }
+//        detail.setAuditButtonStatus(1);
+//        detail.setEvaluateButtonStatus(1);
+//        if((detail.getStatus() == 5 || detail.getStatus() == 7) && systemUserByPhone.isPresent()){
+//            ComplaintAuditRecord one = complaintAuditRecordService.getOne(new LambdaQueryWrapper<ComplaintAuditRecord>().eq(ComplaintAuditRecord::getComplaintId, detail.getId())
+//                    .eq(ComplaintAuditRecord::getLatestFlag, 1));
+//            Integer isAdmin = systemUserByPhone.get().getIsAdmin();
+//            if(one.getReportType().equals(accountLevel) && one.getSuperiorId().toString().equals(targetId) && 1 == isAdmin){
+//                detail.setAuditButtonStatus(0);
+//            }
+//        }
     
     
         buttonPermission(detail, systemUserByPhone);
@@ -577,14 +585,17 @@
                 .ne(SystemUser::getStatus, 3)
                 .last("LIMIT 1"));
 
+        IdentityInformationVO identityInformationVO = identityInformationService.getIdentityInformationVO(loginUserInfoVO);
+        if (CollectionUtil.isEmpty(identityInformationVO.getPermissions())) {
+            throw new ServiceException("请先完成认证");
+        }
+
         Long superiorId;
         int reportType;
         if (adminUser == null) {
-            superiorId = loginUserInfoVO.getCommunityId();
-            if (Objects.isNull(superiorId)) {
-                throw new ServiceException("上报失败,请绑定社区");
-            }
-            reportType = ReportTypeEnum.COMMUNITY.getCode();
+            PartyMember partyMember = partyMemberService.getPartyMemberByPhone(phone);
+            superiorId = partyMember.getCommunityId();
+            reportType = 4;
         } else {
             int accountLevel = adminUser.getAccountLevel(); // 改为基本类型
             if (accountLevel == 1) {
@@ -745,16 +756,24 @@
     @Override
     @Transactional(rollbackFor = Exception.class)
     public void saveDelay(ComplaintDelayDTO dto, LoginUserInfoVO loginUserInfoVO) {
+        IdentityInformationVO identityInformationVO = identityInformationService.getIdentityInformationVO(loginUserInfoVO);
+        List<PermissionsVO> permissions = identityInformationVO.getPermissions();
+
+        if (CollectionUtil.isEmpty(permissions)){
+            throw new ServiceException("请先完成认证");
+        }
+
         SystemUser systemUser = systemUserService.getSystemUserAdminByPhone(loginUserInfoVO.getPhone()).orElse(null);
         Long superiorId;
         int reportType;
-        if (systemUser == null) {
-            superiorId = loginUserInfoVO.getCommunityId();
+        if (identityInformationVO.getIdentity() == 1) {
+            PartyMember partyMember = partyMemberService.getPartyMemberByPhone(loginUserInfoVO.getPhone());
+            superiorId = partyMember.getCommunityId();
             if (Objects.isNull(superiorId)) {
                 throw new ServiceException("延期申请失败,请绑定社区");
             }
             reportType = ReportTypeEnum.COMMUNITY.getCode();
-        } else {
+        } else if (identityInformationVO.getIdentity() == 2){
             int accountLevel = systemUser.getAccountLevel(); // 改为基本类型
             if (accountLevel == 1) {
                 throw new ServiceException("市级账号,无法延期申请!");
@@ -774,6 +793,8 @@
                 // 处理未预期的账号等级
                 throw new ServiceException("未知的账号等级");
             }
+        }else {
+            throw new ServiceException("无权申请");
         }
 
         // 清除最新记录

--
Gitblit v1.7.1