liujie
2025-06-03 c073330664d8b368eb820ee48fcd99226c70366f
springcloud_k8s_panzhihuazhihuishequ/service_westcommittee/src/main/java/com/panzhihua/westcommittee/service/impl/ComplaintServiceImpl.java
@@ -297,6 +297,7 @@
                // 是管理员 看所有的
                page =  baseMapper.selectComplaintPage3(page, query, accountLevel, targetId);
            }else {
                // 不是管理员 看到指派给我的单位的诉求
                page =  baseMapper.selectComplaintPage4(page, query, systemUser.getOneDepartmentId());
            }
@@ -320,6 +321,31 @@
            }
        }
        for (ComplaintVO record : page.getRecords()) {
            int count = complaintCommentService.count(new LambdaQueryWrapper<ComplaintComment>().eq(ComplaintComment::getComplaintId, record.getId()));
            if (count > 0) {
                record.setEvaluateButtonStatus(1);
            } else {
                if (systemUser != null) {
                    if (record.getStatus() == 3 && systemUser.getAccountLevel() == record.getNowLevel()) {
                        record.setEvaluateButtonStatus(0);
                    } else if (record.getCreateBy().equals(loginUserInfoVO.getUserId()) && record.getStatus() == 3) {
                        record.setEvaluateButtonStatus(0);
                    } else {
                        record.setEvaluateButtonStatus(1);
                    }
                } else {
                    if (record.getStatus() == 3 && loginUserInfoVO.getUserId().equals(record.getCreateBy())) {
                        record.setEvaluateButtonStatus(0);
                    } else {
                        record.setEvaluateButtonStatus(1);
                    }
                }
            }
        }
        return page;
    }
@@ -595,8 +621,9 @@
        // 更新状态 此时status是表中的状态 未做变动
        // 如果是区级
        if(systemUser!=null) {
            ComplaintAuditRecord one = complaintAuditRecordService.getOne(new LambdaQueryWrapper<ComplaintAuditRecord>().eq(ComplaintAuditRecord::getComplaintId, id).eq(ComplaintAuditRecord::getLatestFlag, 1).last("limit 1"));
            if (systemUser.getAccountLevel() == 2) {
                if(detail.getNowLevel()==2 && detail.getAssignStatus()==0){
                if (detail.getNowLevel() == 2 && detail.getAssignStatus() == 0 && one != null && one.getAuditStatus() == 1) {
                    detail.setStatus(-1);
                }
                if (systemUser.getSystemRoleId() == 0) {
@@ -605,9 +632,13 @@
                        detail.setStatus(0);
                    }
                }
                if (detail.getFirstStatus() == 0) {
                    detail.setStatus(-2);
                }
            }
            if (systemUser.getAccountLevel() == 3) {
                if(detail.getNowLevel()==3 && detail.getAssignStatus()==0){
                if (detail.getNowLevel() == 3 && detail.getAssignStatus() == 0 && one != null && one.getAuditStatus() == 1) {
                    detail.setStatus(-1);
                }
                if (systemUser.getSystemRoleId() == 0) {
@@ -616,9 +647,12 @@
                        detail.setStatus(0);
                    }
                }
                if (detail.getFirstStatus() == 0) {
                    detail.setStatus(-2);
                }
            }
            if (systemUser.getAccountLevel() == 4) {
                if(detail.getNowLevel()==4 && detail.getAssignStatus()==0){
                if (detail.getNowLevel() == 4 && detail.getAssignStatus() == 0 && one != null && one.getAuditStatus() == 1) {
                    detail.setStatus(-1);
                }
                if (systemUser.getSystemRoleId() == 0) {
@@ -626,6 +660,9 @@
                    if (detail.getNowLevel() != 4 && detail.getStatus() != 3 && detail.getStatus() != 8) {
                        detail.setStatus(0);
                    }
                }
                if (detail.getFirstStatus() == 0) {
                    detail.setStatus(-2);
                }
            }
        }else {
@@ -664,12 +701,11 @@
        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()){
                Integer isAdmin = systemUser.getIsAdmin();
                if(accountLevel.compareTo(detail.getReportType()) == 0 && ((accountLevel != 5 && 1 == isAdmin) || accountLevel == 5)){
                if (accountLevel.compareTo(detail.getNowLevel()) == 0) {
                    detail.setEvaluateButtonStatus(0);
                }
            }else{
                if(detail.getReportType() == 5){
                if (detail.getCreateBy().equals(loginUserInfoVO.getUserId())) {
                    detail.setEvaluateButtonStatus(0);
                }
            }
@@ -916,7 +952,7 @@
                .eq(ComplaintAuditRecord::getComplaintId, dto.getComplaintId())
                .eq(ComplaintAuditRecord::getAuditType, 2)
                .eq(ComplaintAuditRecord::getLatestFlag, false)
                .orderByDesc(ComplaintAuditRecord::getSort)
                .orderByDesc(ComplaintAuditRecord::getSort).last("limit 1")
        );
        if (Objects.nonNull(lastRecord)) {
            // 复制上一条记录
@@ -928,6 +964,12 @@
            newRecord.setUpdateTime(new Date());
            complaintAuditRecordService.save(newRecord);
        }
        // 返回原来的层级
        Complaint complaint = this.getById(dto.getComplaintId());
        complaint.setNowLevel(complaint.getLastLevel());
        complaint.setSuperiorId(complaint.getLastSuperiorId());
        this.updateById(complaint);
    }
    @Override
@@ -1056,8 +1098,6 @@
        }
        if (complaintReporAuditDTO.getAuditResult().equals(1)) {
            complaintAuditRecord.setAuditStatus(1);
            complaintAuditRecord.setAuditorId(loginUserInfoVO.getUserId());
@@ -1075,6 +1115,7 @@
            complaint.setAssignStatus(1);
             complaint.setLastSuperiorId(complaint.getSuperiorId());
             complaint.setLastLevel(complaint.getNowLevel());
            complaint.setRemark(complaintReporAuditDTO.getRemark());
            this.updateById(complaint);
@@ -1204,20 +1245,19 @@
    public void delayAudit(ComplaintDelayAuditDTO dto, LoginUserInfoVO loginUserInfoVO) {
        IdentityInformation identityInformation = identityInformationService.getCurrentIdentityInformation(loginUserInfoVO);
        SystemUser systemUser = identityInformation.getSystemUser();
        SystemUserLevel systemUserLevel = identityInformation.getSystemUserLevel();
        if (identityInformation.getIdentity() != 2) {
            throw new ServiceException("无权审核");
        }
        int accountLevel = systemUserLevel.getLevel(); // 改为基本类型
        int accountLevel = systemUser.getAccountLevel(); // 改为基本类型
        Long superiorId;
        // 使用基本类型比较并补充默认分支
        if (accountLevel == ReportTypeEnum.COMMUNITY.getCode()) {
            superiorId = systemUserLevel.getCommunityId();
            superiorId = systemUser.getCommunityId();
        } else if (accountLevel == ReportTypeEnum.STREET.getCode()) {
            superiorId = Long.parseLong(systemUserLevel.getStreetId());
            superiorId = Long.parseLong(systemUser.getStreetId());
        } else if (accountLevel == ReportTypeEnum.DISTRICT.getCode()) {
            superiorId = Long.parseLong(systemUserLevel.getDistrictsCode());
            superiorId = Long.parseLong(systemUser.getDistrictsCode());
        } else if (accountLevel == ReportTypeEnum.CITY.getCode()) {
            superiorId = 510400L;
        } else {
@@ -1303,6 +1343,26 @@
        } else {
            // 处理未预期的账号等级
            throw new ServiceException("未知的账号等级");
        }
        return dispatchVOList;
    }
    @Override
    public List<DispatchVO> getAllocationList(LoginUserInfoVO loginUserInfo) {
        IdentityInformation identityInformation = identityInformationService.getCurrentIdentityInformation(loginUserInfo);
        List<DispatchVO> dispatchVOList = new ArrayList<>();
        SystemUser adminUser = identityInformation.getSystemUser();
        if (adminUser.getSystemRoleId() != 1) {
            throw new ServiceException("无权查看");
        }
        Integer oneDepartmentId = adminUser.getOneDepartmentId();
        Department byId = departmentService.getById(oneDepartmentId);
        List<Department> list1 = departmentService.list(new LambdaQueryWrapper<Department>().eq(Department::getTier, byId.getTier()));
        for (Department department : list1) {
            DispatchVO dispatchVO = new DispatchVO();
            dispatchVO.setId(department.getId().toString());
            dispatchVO.setName(department.getName());
            dispatchVOList.add(dispatchVO);
        }
        return dispatchVOList;
    }
@@ -1899,13 +1959,16 @@
    }
    @Override
    public void assignComplain(LoginUserInfoVO loginUserInfo, Long complainId, Integer userId,String remark) {
        IdentityInformation currentIdentityInformation = identityInformationService.getCurrentIdentityInformation(loginUserInfo);
        if (currentIdentityInformation.getIdentity().equals(2)) {
            SystemUser systemUser = currentIdentityInformation.getSystemUser();
            Complaint complaint = baseMapper.selectById(complainId);
            if (systemUser.getSystemRoleId() != 1 || !complaint.getNowLevel().equals(systemUser.getAccountLevel())) {
                throw new ServiceException("你没有分配权限");
            }
            // 已分配状态
            complaint.setAssignPersonId(userId);
            complaint.setFirstStatus(1);
@@ -1917,5 +1980,7 @@
        }
    }
}