From d6fbbe9d1b6b1304f37221c8d11a3299a800bcbb Mon Sep 17 00:00:00 2001 From: luofl <1442745593@qq.com> Date: 星期二, 18 三月 2025 14:35:05 +0800 Subject: [PATCH] bug修改 --- springcloud_k8s_panzhihuazhihuishequ/service_sangeshenbian/src/main/java/com/panzhihua/sangeshenbian/service/impl/ComplaintServiceImpl.java | 197 +++++++++++++++++++++++++++--------------------- 1 files changed, 110 insertions(+), 87 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 9068d65..ef16096 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 @@ -7,38 +7,26 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.deepoove.poi.XWPFTemplate; +import com.panzhihua.common.exceptions.ServiceException; import com.panzhihua.common.model.vos.LoginUserInfoVO; import com.panzhihua.common.model.vos.sangeshenbian.SystemUserVo; -import com.panzhihua.common.redis.RedisUtils; +import com.panzhihua.sangeshenbian.dao.ComplaintMapper; +import com.panzhihua.sangeshenbian.enums.ProcessStatusEnum; import com.panzhihua.sangeshenbian.enums.RateEnum; -import com.panzhihua.sangeshenbian.model.dto.ComplaintCompletionDTO; -import com.panzhihua.sangeshenbian.model.dto.ComplaintProcessDTO; -import com.panzhihua.sangeshenbian.model.entity.Complaint; -import com.panzhihua.common.exceptions.ServiceException; import com.panzhihua.sangeshenbian.enums.ReportTypeEnum; import com.panzhihua.sangeshenbian.model.dto.*; import com.panzhihua.sangeshenbian.model.entity.*; -import com.panzhihua.sangeshenbian.enums.ProcessStatusEnum; -import com.panzhihua.sangeshenbian.dao.ComplaintMapper; -import com.panzhihua.sangeshenbian.model.entity.ComplaintFlow; -import com.panzhihua.sangeshenbian.model.entity.ComplaintProgress; -import com.panzhihua.sangeshenbian.model.entity.SystemUser; import com.panzhihua.sangeshenbian.model.excel.ComplaintExcel; -import com.panzhihua.sangeshenbian.model.excel.PartyMemberExcel; import com.panzhihua.sangeshenbian.model.query.BasePage; import com.panzhihua.sangeshenbian.model.query.ComplaintQuery; import com.panzhihua.sangeshenbian.model.vo.ComplaintTodoVO; -import com.panzhihua.sangeshenbian.service.IComplaintFlowService; -import com.panzhihua.sangeshenbian.service.IComplaintProgressService; -import com.panzhihua.sangeshenbian.service.IComplaintService; +import com.panzhihua.sangeshenbian.model.vo.ComplaintVO; import com.panzhihua.sangeshenbian.model.vo.DispatchVO; import com.panzhihua.sangeshenbian.service.*; -import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; -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.IdentityInformation; import com.panzhihua.sangeshenbian.warpper.MgtComplaintQuery; import com.panzhihua.sangeshenbian.warpper.PermissionsVO; import lombok.RequiredArgsConstructor; @@ -51,13 +39,7 @@ import java.io.IOException; import java.net.URLEncoder; import java.text.SimpleDateFormat; -import java.util.ArrayList; -import java.util.Date; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Objects; -import java.util.Optional; +import java.util.*; import static cn.hutool.core.util.ObjectUtil.isNull; @@ -86,7 +68,6 @@ private final HttpServletResponse response; private final IPartyMemberService partyMemberService; private final IdentityInformationService identityInformationService; - private final RedisUtils redisUtils; @Override public void saveComplaint(Complaint complaint, LoginUserInfoVO loginUserInfoVO) { @@ -112,14 +93,17 @@ // 设置流水号 complaint.setSerialNumber(serialNumber); - Optional<SystemUser> systemUserOpt = systemUserService.getSystemUserAdminByPhone(loginUserInfoVO.getPhone()); Integer accountLevel = 5; //获取当前身份 - IdentityInformationVO identityInformationVO = identityInformationService.getIdentityInformationVO(loginUserInfoVO); + IdentityInformation identityInformationVO = identityInformationService.getIdentityInformation(loginUserInfoVO); //1=党员,2=管理员 + SystemUser systemUser = identityInformationVO.getSystemUser(); + List<PermissionsVO> permissions = identityInformationVO.getPermissions(); + if (permissions.isEmpty()) { + throw new ServiceException("请先完善个人信息"); + } Integer identity = identityInformationVO.getIdentity(); - if (systemUserOpt.isPresent() && null != identity && identity == 2) { - SystemUser systemUser = systemUserOpt.get(); + if (identity == 2) { accountLevel = systemUser.getAccountLevel(); switch (accountLevel) { case 1: @@ -192,11 +176,6 @@ save(complaint); } - /** - * @param query - * @param loginUserInfoVO - * @return - */ @Override public Page<ComplaintVO> complaintList(ComplaintQuery query, LoginUserInfoVO loginUserInfoVO) { Page<ComplaintVO> page = new Page<>(query.getPageNum(), query.getPageSize()); @@ -205,7 +184,11 @@ Long targetId = null; Integer accountLevel = 5; //获取当前身份,1=党员,2=管理员 - Integer identity = (Integer) redisUtils.get("identity:" + loginUserInfoVO.getPhone()); + IdentityInformation identityInformation = identityInformationService.getIdentityInformation(loginUserInfoVO); + if (CollectionUtil.isEmpty(identityInformation.getPermissions())){ + throw new ServiceException("请先完善个人信息"); + } + Integer identity = identityInformation.getIdentity(); //上级 if (systemUserByPhone.isPresent() && null != identity && identity == 2) { SystemUser systemUser = systemUserByPhone.get(); @@ -241,18 +224,15 @@ //查询对应诉求 //page = baseMapper.selectComplaintPage(page, query, targetId, isSuperior); page = baseMapper.selectComplaintPage1(page, query, accountLevel, targetId); - page.getRecords().forEach(s->{ - buttonPermission(s, systemUserByPhone); - }); + page.getRecords().forEach(s-> buttonPermission(s, systemUserByPhone, loginUserInfoVO)); return page; } /** * 列表按钮权限 - * @param vo */ - public void buttonPermission(ComplaintVO vo, Optional<SystemUser> systemUserByPhone){ + public void buttonPermission(ComplaintVO vo, Optional<SystemUser> systemUserByPhone, LoginUserInfoVO loginUserInfo){ vo.setListControlsButtonStatus(1); vo.setEvaluateButtonStatus(1); vo.setAuditButtonStatus(1); @@ -387,8 +367,8 @@ String targetId = ""; Integer accountLevel = 5; //获取当前身份,1=党员,2=管理员 - Integer identity = (Integer) redisUtils.get("identity:" + systemUser.getPhone()); - if(2 == identity){ + IdentityInformation identityInformation = identityInformationService.getIdentityInformation(loginUserInfo); + if(2 == identityInformation.getIdentity()){ accountLevel = systemUser.getAccountLevel(); switch (accountLevel) { case 1: @@ -455,7 +435,11 @@ String targetId = ""; Integer accountLevel = 5; //获取当前身份,1=党员,2=管理员 - Integer identity = (Integer) redisUtils.get("identity:" + loginUserInfoVO.getPhone()); + IdentityInformation identityInformation = identityInformationService.getIdentityInformation(loginUserInfoVO); + if (CollectionUtil.isEmpty(identityInformation.getPermissions())){ + throw new ServiceException("身份信息异常"); + } + Integer identity = identityInformation.getIdentity(); //上级 if (systemUserByPhone.isPresent() && identity == 2) { SystemUser systemUser = systemUserByPhone.get(); @@ -509,7 +493,7 @@ // } - buttonPermission(detail, systemUserByPhone); + buttonPermission(detail, systemUserByPhone, loginUserInfoVO); // //已办结,显示评价按钮 @@ -585,18 +569,20 @@ .ne(SystemUser::getStatus, 3) .last("LIMIT 1")); - IdentityInformationVO identityInformationVO = identityInformationService.getIdentityInformationVO(loginUserInfoVO); + IdentityInformation identityInformationVO = identityInformationService.getIdentityInformation(loginUserInfoVO); if (CollectionUtil.isEmpty(identityInformationVO.getPermissions())) { throw new ServiceException("请先完成认证"); } Long superiorId; int reportType; - if (adminUser == null) { + if (identityInformationVO.getIdentity() == 1) { + + PartyMember partyMember = partyMemberService.getPartyMemberByPhone(phone); superiorId = partyMember.getCommunityId(); reportType = 4; - } else { + } else if (identityInformationVO.getIdentity() == 2) { int accountLevel = adminUser.getAccountLevel(); // 改为基本类型 if (accountLevel == 1) { throw new ServiceException("市级账号,无法上报!"); @@ -616,6 +602,8 @@ // 处理未预期的账号等级 throw new ServiceException("未知的账号等级"); } + }else { + throw new ServiceException("未知的账号等级"); } Complaint complaint = getById(dto.getComplaintId()); @@ -651,17 +639,16 @@ @Override @Transactional(rollbackFor = Exception.class) public void saveDispatch(ComplaintDispatch dto, LoginUserInfoVO loginUserInfoVO) { - String phone = loginUserInfoVO.getPhone(); - SystemUser adminUser = systemUserService.getOne(new LambdaQueryWrapper<SystemUser>() - .eq(SystemUser::getPhone, phone) - .eq(SystemUser::getIsAdmin, 1) - .ne(SystemUser::getStatus, 3) - .last("LIMIT 1")); - - if (adminUser == null) { + IdentityInformation identityInformation = identityInformationService.getIdentityInformation(loginUserInfoVO); + List<PermissionsVO> permissions = identityInformation.getPermissions(); + if (CollectionUtil.isEmpty(permissions)) { + throw new ServiceException("请先完成认证"); + } + if (identityInformation.getIdentity() != 2) { throw new ServiceException("无权下派"); } + SystemUser adminUser = identityInformation.getSystemUser(); int accountLevel = adminUser.getAccountLevel(); // 改为基本类型 if (accountLevel == 4) { throw new ServiceException("社区账号,无法下派!"); @@ -669,18 +656,16 @@ accountLevel++; Complaint complaint = getById(dto.getComplaintId()); - updateById(complaint); //查询当前单位审核记录表数据 //查询上报审核记录 - ComplaintAuditRecord complaintAuditRecord = complaintAuditRecordService.lambdaQuery() - .eq(ComplaintAuditRecord::getComplaintId, dto.getComplaintId()) - .eq(ComplaintAuditRecord::getAuditType, 0) - .eq(ComplaintAuditRecord::getLatestFlag, true) - .eq(ComplaintAuditRecord::getReportType, adminUser.getAccountLevel()) - .last("LIMIT 1").one(); +// ComplaintAuditRecord complaintAuditRecord = complaintAuditRecordService.lambdaQuery() +// .eq(ComplaintAuditRecord::getComplaintId, dto.getComplaintId()) +// .eq(ComplaintAuditRecord::getAuditType, 0) +// .eq(ComplaintAuditRecord::getLatestFlag, true) +// .eq(ComplaintAuditRecord::getReportType, adminUser.getAccountLevel()) +// .last("LIMIT 1").one(); // 添加流转记录 - complaintFlowService.createFlow(complaintAuditRecord, 1,loginUserInfoVO.getUserId()); - +// complaintFlowService.createFlow(complaintAuditRecord, 1,loginUserInfoVO.getUserId()); // 标记最新 complaintAuditRecordService.update(new LambdaUpdateWrapper<ComplaintAuditRecord>() .eq(ComplaintAuditRecord::getComplaintId, dto.getComplaintId()) @@ -700,17 +685,43 @@ record.setSuperiorId(dto.getDispatchId()); record.setSort(count + 1); complaintAuditRecordService.save(record); + ComplaintAuditRecord complaintAuditRecord = new ComplaintAuditRecord(); + complaintAuditRecord.setComplaintId(complaint.getId()); + complaintAuditRecord.setReportType(adminUser.getAccountLevel()); + Long superiorId = null; + switch (adminUser.getAccountLevel()) { + case 1: + superiorId = 510400L;//默认市级 + break; + case 2: + superiorId = Long.parseLong(adminUser.getDistrictsCode()); + break; + case 3: + superiorId = Long.parseLong(adminUser.getStreetId()); + break; + case 4: + superiorId = adminUser.getCommunityId(); + break; + } + complaintAuditRecord.setSuperiorId(superiorId); + complaintFlowService.createFlow(complaintAuditRecord, 1,loginUserInfoVO.getUserId()); } @Override @Transactional(rollbackFor = Exception.class) public void reportAudit(ComplaintReporAuditDTO complaintReporAuditDTO, LoginUserInfoVO loginUserInfoVO) { - Optional<SystemUser> systemUserByPhone = systemUserService.getSystemUserAdminByPhone(loginUserInfoVO.getPhone()); - if (!systemUserByPhone.isPresent()) { + + IdentityInformation identityInformation = identityInformationService.getIdentityInformation(loginUserInfoVO); + List<PermissionsVO> permissions = identityInformation.getPermissions(); + if (CollectionUtil.isEmpty(permissions)) { + throw new ServiceException("请先完成认证"); + } + + SystemUser systemUser = identityInformation.getSystemUser(); + if (systemUser == null || identityInformation.getIdentity() != 2) { throw new ServiceException("无权审核"); } - SystemUser systemUser = systemUserByPhone.get(); Long superiorId = 0L; switch (systemUser.getAccountLevel()) { case 1: @@ -756,8 +767,8 @@ @Override @Transactional(rollbackFor = Exception.class) public void saveDelay(ComplaintDelayDTO dto, LoginUserInfoVO loginUserInfoVO) { - IdentityInformationVO identityInformationVO = identityInformationService.getIdentityInformationVO(loginUserInfoVO); - List<PermissionsVO> permissions = identityInformationVO.getPermissions(); + IdentityInformation identityInformation = identityInformationService.getIdentityInformation(loginUserInfoVO); + List<PermissionsVO> permissions = identityInformation.getPermissions(); if (CollectionUtil.isEmpty(permissions)){ throw new ServiceException("请先完成认证"); @@ -766,14 +777,14 @@ SystemUser systemUser = systemUserService.getSystemUserAdminByPhone(loginUserInfoVO.getPhone()).orElse(null); Long superiorId; int reportType; - if (identityInformationVO.getIdentity() == 1) { + if (identityInformation.getIdentity() == 1) { PartyMember partyMember = partyMemberService.getPartyMemberByPhone(loginUserInfoVO.getPhone()); superiorId = partyMember.getCommunityId(); if (Objects.isNull(superiorId)) { throw new ServiceException("延期申请失败,请绑定社区"); } reportType = ReportTypeEnum.COMMUNITY.getCode(); - } else if (identityInformationVO.getIdentity() == 2){ + } else if (identityInformation.getIdentity() == 2 && systemUser!=null){ int accountLevel = systemUser.getAccountLevel(); // 改为基本类型 if (accountLevel == 1) { throw new ServiceException("市级账号,无法延期申请!"); @@ -822,7 +833,16 @@ @Override public void delayAudit(ComplaintDelayAuditDTO dto, LoginUserInfoVO loginUserInfoVO) { - SystemUser systemUser = systemUserService.getSystemUserAdminByPhone(loginUserInfoVO.getPhone()).orElse(null); + IdentityInformation identityInformation = identityInformationService.getIdentityInformation(loginUserInfoVO); + List<PermissionsVO> permissions = identityInformation.getPermissions(); + if (CollectionUtil.isEmpty(permissions)){ + throw new ServiceException("请先完成认证"); + } + SystemUser systemUser = identityInformation.getSystemUser(); + if (identityInformation.getIdentity() != 2 || systemUser == null){ + throw new ServiceException("无权审核"); + } + int accountLevel = systemUser.getAccountLevel(); // 改为基本类型 Long superiorId; // 使用基本类型比较并补充默认分支 @@ -875,14 +895,11 @@ @Override public List<DispatchVO> getDispatchList(LoginUserInfoVO loginUserInfoVO) { - String phone = loginUserInfoVO.getPhone(); - SystemUser adminUser = systemUserService.getOne(new LambdaQueryWrapper<SystemUser>() - .eq(SystemUser::getPhone, phone) - .eq(SystemUser::getIsAdmin, 1) - .ne(SystemUser::getStatus, 3) - .last("LIMIT 1")); + IdentityInformation identityInformation = identityInformationService.getIdentityInformation(loginUserInfoVO); - if (adminUser == null) { + SystemUser adminUser = identityInformation.getSystemUser(); + + if (adminUser == null || identityInformation.getIdentity() != 2) { throw new ServiceException("无权下派"); } int accountLevel = adminUser.getAccountLevel(); // 改为基本类型 @@ -935,12 +952,16 @@ */ @Override public Page<ComplaintTodoVO> getTodoList(BasePage basePage, LoginUserInfoVO loginUserInfo) { - Optional<SystemUser> systemUserByPhone = systemUserService.getSystemUserAdminByPhone(loginUserInfo.getPhone()); + IdentityInformation identityInformation = identityInformationService.getIdentityInformation(loginUserInfo); + List<PermissionsVO> permissions = identityInformation.getPermissions(); + SystemUser systemUser = identityInformation.getSystemUser(); + if (permissions.isEmpty()) { + throw new ServiceException("无权限"); + } String targetId = ""; int isSuperior = 0; //上级 - if (systemUserByPhone.isPresent()) { - SystemUser systemUser = systemUserByPhone.get(); + if (identityInformation.getIdentity() == 2) { Integer accountLevel = systemUser.getAccountLevel(); switch (accountLevel) { case 1: @@ -953,7 +974,7 @@ break; case 3: //街道 - targetId = systemUser.getStreetId().toString(); + targetId = systemUser.getStreetId(); break; case 4: //社区 @@ -965,8 +986,7 @@ //党员 targetId = loginUserInfo.getUserId().toString(); } - Page<ComplaintTodoVO> page = baseMapper.getTodoList(new Page<>(basePage.getPageNum(), basePage.getPageSize()), targetId, isSuperior); - return page; + return baseMapper.getTodoList(new Page<>(basePage.getPageNum(), basePage.getPageSize()), targetId, isSuperior); } /** @@ -1003,7 +1023,10 @@ List<ComplaintProgress> complaintProgresses = complaintProgressService.lambdaQuery().eq(ComplaintProgress::getComplaintId, id).orderByAsc(ComplaintProgress::getCreateTime).list(); complaintVO.setComplaintProgresses(complaintProgresses); //查询诉求流转记录 - List<ComplaintFlow> complaintFlows = complaintFlowService.lambdaQuery().eq(ComplaintFlow::getComplaintId, id).orderByAsc(ComplaintFlow::getCreateTime).list(); + List<ComplaintFlow> complaintFlows = complaintFlowService.lambdaQuery() + .eq(ComplaintFlow::getComplaintId, id) + .orderByDesc(ComplaintFlow::getCreateTime) + .list(); complaintVO.setComplaintFlows(complaintFlows); //查询评价 ComplaintComment comment = complaintCommentService.lambdaQuery().eq(ComplaintComment::getComplaintId, id).last("LIMIT 1").one(); -- Gitblit v1.7.1