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 |  164 +++++++++++++++++++++++++++++++++++++++---------------
 1 files changed, 117 insertions(+), 47 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 36131d9..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,9 +114,11 @@
         complaint.setSerialNumber(serialNumber);
         Optional<SystemUser> systemUserOpt = systemUserService.getSystemUserAdminByPhone(loginUserInfoVO.getPhone());
         Integer accountLevel = 5;
-        //获取当前身份,1=党员,2=管理员
-        Integer identity = (Integer) redisUtils.get("identity:" + loginUserInfoVO.getPhone());
-        if (systemUserOpt.isPresent() && identity == 2) {
+        //获取当前身份
+        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();
             switch (accountLevel) {
@@ -201,7 +207,7 @@
         //获取当前身份,1=党员,2=管理员
         Integer identity = (Integer) redisUtils.get("identity:" + loginUserInfoVO.getPhone());
         //上级
-        if (systemUserByPhone.isPresent() && identity == 2) {
+        if (systemUserByPhone.isPresent() && null != identity && identity == 2) {
             SystemUser systemUser = systemUserByPhone.get();
             accountLevel = systemUser.getAccountLevel();
             switch (accountLevel) {
@@ -249,6 +255,8 @@
     public void buttonPermission(ComplaintVO vo, Optional<SystemUser> systemUserByPhone){
         vo.setListControlsButtonStatus(1);
         vo.setEvaluateButtonStatus(1);
+        vo.setAuditButtonStatus(1);
+        
         ComplaintAuditRecord one = complaintAuditRecordService.getOne(new LambdaQueryWrapper<ComplaintAuditRecord>().eq(ComplaintAuditRecord::getComplaintId, vo.getId())
                 .ne(ComplaintAuditRecord::getAuditType, 1).orderByDesc(ComplaintAuditRecord::getSort).last(" limit 0, 1"));
         //没有审核数据,且正在办理,则按钮权限是添加人员的
@@ -268,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){
                 //判断当前审核状态
@@ -371,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));
@@ -445,31 +497,36 @@
         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);
-            }
-        }
-        //已办结,显示评价按钮
-        int count = complaintCommentService.count(new LambdaQueryWrapper<ComplaintComment>().eq(ComplaintComment::getComplaintId, detail.getId()).eq(ComplaintComment::getDelFlag, 0));
-        if(detail.getStatus() == 3 && 0 == count){
-            if(systemUserByPhone.isPresent()){
-                SystemUser systemUser = systemUserByPhone.get();
-                Integer isAdmin = systemUser.getIsAdmin();
-                if(accountLevel.compareTo(detail.getReportType()) == 0 && ((accountLevel != 5 && 1 == isAdmin) || accountLevel == 5)){
-                    detail.setEvaluateButtonStatus(0);
-                }
-            }else{
-                if(detail.getReportType() == 5){
-                    detail.setEvaluateButtonStatus(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);
+        
+        
+//        //已办结,显示评价按钮
+//        int count = complaintCommentService.count(new LambdaQueryWrapper<ComplaintComment>().eq(ComplaintComment::getComplaintId, detail.getId()).eq(ComplaintComment::getDelFlag, 0));
+//        if(detail.getStatus() == 3 && 0 == count){
+//            if(systemUserByPhone.isPresent()){
+//                SystemUser systemUser = systemUserByPhone.get();
+//                Integer isAdmin = systemUser.getIsAdmin();
+//                if(accountLevel.compareTo(detail.getReportType()) == 0 && ((accountLevel != 5 && 1 == isAdmin) || accountLevel == 5)){
+//                    detail.setEvaluateButtonStatus(0);
+//                }
+//            }else{
+//                if(detail.getReportType() == 5){
+//                    detail.setEvaluateButtonStatus(0);
+//                }
+//            }
+//        }
         return detail;
     }
 
@@ -528,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) {
@@ -696,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("市级账号,无法延期申请!");
@@ -725,6 +793,8 @@
                 // 处理未预期的账号等级
                 throw new ServiceException("未知的账号等级");
             }
+        }else {
+            throw new ServiceException("无权申请");
         }
 
         // 清除最新记录
@@ -954,22 +1024,22 @@
         response.setCharacterEncoding("utf-8");
         String fileName = URLEncoder.encode("诉求数据", "UTF-8").replaceAll("\\+", "%20");
         response.setHeader("Content-disposition", "attachment;filename*=utf-8''" + fileName + ".xlsx");
-        EasyExcel.write(response.getOutputStream(), PartyMemberExcel.class)
+        EasyExcel.write(response.getOutputStream(), ComplaintExcel.class)
                 .sheet("诉求数据")
                 .doWrite(complaintExcels);
     }
 
     @Override
     public void downloadFile(Long id,Integer type) throws IOException {
-        Complaint complaint = getById(id);
+        Complaint complaint = baseMapper.getDetailBg(id);
         if (Objects.isNull(complaint)) {
             throw new ServiceException("该诉求不存在");
         }
          //查询社区信息
-        BcRegion region = bcRegionService.lambdaQuery().eq(BcRegion::getRegionCode, complaint.getDistrictsCode()).last("LIMIT 1").one();
-        ComStreet street = comStreetService.lambdaQuery().eq(ComStreet::getStreetId, complaint.getStreetId()).one();
-        ComAct act = comActService.lambdaQuery().eq(ComAct::getCommunityId, complaint.getCommunityId()).one();
-        String community = region.getRegionName() +"-"+ street.getName() + act.getName();
+        BcRegion region = bcRegionService.getDistrictByCode(complaint.getDistrictsCode().toString());
+        ComStreet street = comStreetService.getById(complaint.getStreetId().toString());
+        ComAct act = comActService.getById(complaint.getCommunityId());
+        String community = region.getRegionName() +"-"+ street.getName() + "-"+ act.getName();
         PartyMember partyMember = null;
         if (Objects.nonNull(complaint.getPartyMemberId())){
              partyMember = partyMemberService.getById(complaint.getPartyMemberId());
@@ -993,12 +1063,12 @@
         map.put("community", community);
         map.put("problemType", complaint.getProblemType());
         map.put("descriptionContent", complaint.getDescriptionContent());
-        map.put("reportType", Objects.nonNull(complaint.getPartyMemberId())?"党员": "上级"); //TODO待修改
+        map.put("reportType", ReportTypeEnum.fromCode(complaint.getReportType()).getDescription());
         map.put("partyOrganization",Objects.nonNull(partyMember)? partyMember.getPartyOrganization() : "");
         map.put("name", complaint.getName());
         map.put("contactNumber", complaint.getContactNumber());
-        map.put("nickname", Objects.nonNull(partyMember)? partyMember.getName() : "");
-        map.put("phone", Objects.nonNull(partyMember)? partyMember.getPhone() : "");
+        map.put("nickname", complaint.getReportUserName());
+        map.put("phone", complaint.getReportUserPhone());
         List<ComplaintProgress> list = complaintProgressService.lambdaQuery().eq(ComplaintProgress::getComplaintId, id).orderByAsc(ComplaintProgress::getCreateTime).list();
         StringBuilder sb = new StringBuilder();
         if (CollUtil.isNotEmpty(list)) {

--
Gitblit v1.7.1