From 00ef2e4c4c6a85af857be272cf74a7e43e6517f0 Mon Sep 17 00:00:00 2001 From: Pu Zhibing <393733352@qq.com> Date: 星期日, 16 三月 2025 03:42:16 +0800 Subject: [PATCH] 修改诉求流程和新增评价功能 --- springcloud_k8s_panzhihuazhihuishequ/service_sangeshenbian/src/main/java/com/panzhihua/sangeshenbian/service/impl/ComplaintServiceImpl.java | 587 +++++++++++++++++++++++++++++++++++++++++++++++----------- 1 files changed, 470 insertions(+), 117 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 5d89640..1f23d44 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 @@ -1,6 +1,7 @@ package com.panzhihua.sangeshenbian.service.impl; import cn.hutool.core.bean.BeanUtil; +import com.alibaba.fastjson.JSON; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; @@ -29,6 +30,7 @@ import com.panzhihua.sangeshenbian.model.vo.ComplaintVO; import com.panzhihua.sangeshenbian.service.ISystemUserService; import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; import org.springframework.context.annotation.Lazy; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -50,6 +52,7 @@ * @author * @since 2025-02-22 */ +@Slf4j @Service @RequiredArgsConstructor(onConstructor_ = {@Lazy}) public class ComplaintServiceImpl extends ServiceImpl<ComplaintMapper, Complaint> implements IComplaintService { @@ -62,9 +65,11 @@ private final IComStreetService comStreetService; private final IComActService comActService; private final IWorkOrderItemConfigService workOrderItemConfigService; + private final IPartyMemberService partyMemberService; + private final IComplaintCommentService complaintCommentService; @Override - public void saveComplaint(Complaint complaint, Long userId) { + public void saveComplaint(Complaint complaint, LoginUserInfoVO loginUserInfoVO) { // 获取当前日期(年月日) String datePrefix = new SimpleDateFormat("yyyyMMdd").format(new Date()); @@ -87,16 +92,58 @@ // 设置流水号 complaint.setSerialNumber(serialNumber); - + Optional<SystemUser> systemUserOpt = systemUserService.getSystemUserAdminByPhone(loginUserInfoVO.getPhone()); + Integer accountLevel = 5; + if (systemUserOpt.isPresent()) { + SystemUser systemUser = systemUserOpt.get(); + accountLevel = systemUser.getAccountLevel(); + switch (accountLevel) { + case 1: + //市级 + complaint.setCityCode(510400); + break; + case 2: + //区县级 + complaint.setCityCode(510400); + complaint.setDistrictsCode(Integer.valueOf(systemUser.getDistrictsCode())); + break; + case 3: + //街道 + complaint.setCityCode(510400); + complaint.setDistrictsCode(Integer.valueOf(systemUser.getDistrictsCode())); + complaint.setStreetId(Long.valueOf(systemUser.getStreetId())); + break; + case 4: + //社区 + complaint.setCityCode(510400); + complaint.setDistrictsCode(Integer.valueOf(systemUser.getDistrictsCode())); + complaint.setStreetId(Long.valueOf(systemUser.getStreetId())); + complaint.setCommunityId(systemUser.getCommunityId()); + break; + case 5: + //社区 + complaint.setCityCode(510400); + complaint.setDistrictsCode(Integer.valueOf(systemUser.getDistrictsCode())); + complaint.setStreetId(Long.valueOf(systemUser.getStreetId())); + complaint.setCommunityId(systemUser.getCommunityId()); + PartyMember partyMember = partyMemberService.getPartyMemberByPhone(loginUserInfoVO.getPhone()); + complaint.setPartyMemberId(partyMember.getId()); + break; + } + } else{ + PartyMember partyMember = partyMemberService.getPartyMemberByPhone(loginUserInfoVO.getPhone()); + complaint.setPartyMemberId(partyMember.getId()); + } + complaint.setReportType(accountLevel); // 设置其他字段 complaint.setStatus(ProcessStatusEnum.PROCESSING.getCode()); complaint.setCreateTime(new Date(System.currentTimeMillis())); - complaint.setCreateBy(userId); - complaint.setUpdateBy(userId); + complaint.setCreateBy(loginUserInfoVO.getUserId()); + complaint.setUpdateBy(loginUserInfoVO.getUserId()); complaint.setUpdateTime(new Date(System.currentTimeMillis())); //查询系统配置诉求处理期限,设置截止日期 WorkOrderItemConfig config = workOrderItemConfigService.lambdaQuery().orderByDesc(WorkOrderItemConfig::getId).last("LIMIT 1").one(); - if (Objects.isNull(config)){ + if (Objects.isNull(config)) { throw new ServiceException("工单事项未配置,请联系管理员"); } complaint.setClosingTime(new Date(System.currentTimeMillis() + config.getDemandProcessingTime() * 24 * 60 * 60 * 1000)); @@ -113,13 +160,215 @@ public Page<ComplaintVO> complaintList(ComplaintQuery query, LoginUserInfoVO loginUserInfoVO) { Page<ComplaintVO> page = new Page<>(query.getPageNum(), query.getPageSize()); //判断当前登录用户级别,查询对应工单 - Optional<SystemUser> systemUserByPhone = systemUserService.getSystemUserByPhone(loginUserInfoVO.getPhone()); - String targetId = ""; - int isSuperior = 0; + Optional<SystemUser> systemUserByPhone = systemUserService.getSystemUserAdminByPhone(loginUserInfoVO.getPhone()); + Long targetId = null; + Integer accountLevel = 5; //上级 if (systemUserByPhone.isPresent()) { SystemUser systemUser = systemUserByPhone.get(); - Integer accountLevel = systemUser.getAccountLevel(); + accountLevel = systemUser.getAccountLevel(); + switch (accountLevel) { + case 1: + //市级 + targetId = 510400L; + break; + case 2: + //区县级 + targetId = Long.valueOf(systemUser.getDistrictsCode()); + break; + case 3: + //街道 + targetId = Long.valueOf(systemUser.getStreetId()); + break; + case 4: + //社区 + targetId = systemUser.getCommunityId(); + break; + case 5: + //党员 + PartyMember partyMember = partyMemberService.getPartyMemberByPhone(loginUserInfoVO.getPhone()); + targetId = partyMember.getId(); + break; + } + } else { + //党员 + PartyMember partyMember = partyMemberService.getPartyMemberByPhone(loginUserInfoVO.getPhone()); + targetId = partyMember.getId(); + } + //查询对应诉求 + //page = baseMapper.selectComplaintPage(page, query, targetId, isSuperior); + page = baseMapper.selectComplaintPage1(page, query, accountLevel, targetId); + page.getRecords().forEach(s->{ + buttonPermission(s, systemUserByPhone); + }); + return page; + } + + + /** + * 列表按钮权限 + * @param vo + */ + public void buttonPermission(ComplaintVO vo, Optional<SystemUser> systemUserByPhone){ + vo.setListControlsButtonStatus(1); + vo.setEvaluateButtonStatus(1); + ComplaintAuditRecord one = complaintAuditRecordService.getOne(new LambdaQueryWrapper<ComplaintAuditRecord>().eq(ComplaintAuditRecord::getComplaintId, vo.getId()) + .ne(ComplaintAuditRecord::getAuditType, 1).orderByDesc(ComplaintAuditRecord::getSort).last(" limit 0, 1")); + //没有审核数据,且正在办理,则按钮权限是添加人员的 + if(null == one && (vo.getStatus() == 0 || vo.getStatus() == 1 || vo.getStatus() == 2)){ + if(systemUserByPhone.isPresent()){ + SystemUser systemUser = systemUserByPhone.get(); + Integer accountLevel = systemUser.getAccountLevel(); + Integer isAdmin = systemUser.getIsAdmin(); + //非党员用户,必须是管理员有权限 + if(accountLevel.compareTo(vo.getReportType()) == 0 && ((accountLevel != 5 && 1 == isAdmin) || accountLevel == 5)){ + vo.setListControlsButtonStatus(0); + } + }else{ + if(vo.getReportType() == 5){ + vo.setListControlsButtonStatus(0); + } + } + } + //有审核数据,且正在办理 + if(null != one && (vo.getStatus() == 0 || vo.getStatus() == 1 || vo.getStatus() == 2)){ + //区分是上报数据还是下派数据 + if(one.getAuditType() == 2){ + //判断当前审核状态 + if(one.getAuditStatus() == 1){ + //审核状态为通过,则权限给到上报审核的这一层 + if(systemUserByPhone.isPresent()){ + SystemUser systemUser = systemUserByPhone.get(); + Integer accountLevel = systemUser.getAccountLevel(); + Integer isAdmin = systemUser.getIsAdmin(); + //非党员用户,必须是管理员有权限 + if(accountLevel.compareTo(one.getReportType()) == 0 && accountLevel != 5 && 1 == isAdmin){ + vo.setListControlsButtonStatus(0); + } + } + }else{ + //没有审核通过,则需要查询上一条审核通过的数据,如果没有则给到添加诉求的人 + 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")); + if(null != one1){ + if(systemUserByPhone.isPresent()){ + SystemUser systemUser = systemUserByPhone.get(); + Integer accountLevel = systemUser.getAccountLevel(); + Integer isAdmin = systemUser.getIsAdmin(); + //非党员用户,必须是管理员有权限 + if(accountLevel.compareTo(one1.getReportType()) == 0 && accountLevel != 5 && 1 == isAdmin){ + vo.setListControlsButtonStatus(0); + } + } + }else{ + //没有上一层审核通过的数据,则权限给到添加人 + if(systemUserByPhone.isPresent()){ + SystemUser systemUser = systemUserByPhone.get(); + Integer accountLevel = systemUser.getAccountLevel(); + Integer isAdmin = systemUser.getIsAdmin(); + //非党员用户,必须是管理员有权限 + if(accountLevel.compareTo(vo.getReportType()) == 0 && ((accountLevel != 5 && 1 == isAdmin) || accountLevel == 5)){ + vo.setListControlsButtonStatus(0); + } + }else{ + if(vo.getReportType() == 5){ + vo.setListControlsButtonStatus(0); + } + } + } + } + } + + //下派数据 + if(one.getAuditType() == 3){ + //判断当前审核状态 + if(one.getAuditStatus() == 1){ + //审核状态为通过,则权限给到下报审核的这一层 + if(systemUserByPhone.isPresent()){ + SystemUser systemUser = systemUserByPhone.get(); + Integer accountLevel = systemUser.getAccountLevel(); + Integer isAdmin = systemUser.getIsAdmin(); + //非党员用户,必须是管理员有权限 + if(accountLevel.compareTo(one.getReportType()) == 0 && ((accountLevel != 5 && 1 == isAdmin) || accountLevel == 5)){ + vo.setListControlsButtonStatus(0); + } + }else{ + if(vo.getReportType() == 5 && one.getReportType() == 5){ + vo.setListControlsButtonStatus(0); + } + } + }else{ + //没有审核通过,则需要查询上一条审核通过的数据,如果没有则给到添加诉求的人 + ComplaintAuditRecord one1 = complaintAuditRecordService.getOne(new LambdaQueryWrapper<ComplaintAuditRecord>().eq(ComplaintAuditRecord::getComplaintId, vo.getId()) + .eq(ComplaintAuditRecord::getAuditType, 3).eq(ComplaintAuditRecord::getAuditStatus, 1).orderByDesc(ComplaintAuditRecord::getSort).last(" limit 0, 1")); + if(null != one1){ + if(systemUserByPhone.isPresent()){ + SystemUser systemUser = systemUserByPhone.get(); + Integer accountLevel = systemUser.getAccountLevel(); + Integer isAdmin = systemUser.getIsAdmin(); + //非党员用户,必须是管理员有权限 + if(accountLevel.compareTo(one1.getReportType()) == 0 && ((accountLevel != 5 && 1 == isAdmin) || accountLevel == 5)){ + vo.setListControlsButtonStatus(0); + } + }else{ + if(vo.getReportType() == 5 && one1.getReportType() == 5){ + vo.setListControlsButtonStatus(0); + } + } + }else{ + //没有上一层审核通过的数据,则权限给到添加人 + if(systemUserByPhone.isPresent()){ + SystemUser systemUser = systemUserByPhone.get(); + Integer accountLevel = systemUser.getAccountLevel(); + Integer isAdmin = systemUser.getIsAdmin(); + //非党员用户,必须是管理员有权限 + if(accountLevel.compareTo(vo.getReportType()) == 0 && ((accountLevel != 5 && 1 == isAdmin) || accountLevel == 5)){ + vo.setListControlsButtonStatus(0); + } + }else{ + if(vo.getReportType() == 5){ + vo.setListControlsButtonStatus(0); + } + } + } + } + } + } + + //状态为已办结,判断评价按钮 + int count = complaintCommentService.count(new LambdaQueryWrapper<ComplaintComment>().eq(ComplaintComment::getComplaintId, vo.getId()).eq(ComplaintComment::getDelFlag, 0)); + if(vo.getStatus() == 3 && 0 == count){ + if(systemUserByPhone.isPresent()){ + SystemUser systemUser = systemUserByPhone.get(); + Integer accountLevel = systemUser.getAccountLevel(); + Integer isAdmin = systemUser.getIsAdmin(); + if(accountLevel.compareTo(vo.getReportType()) == 0 && ((accountLevel != 5 && 1 == isAdmin) || accountLevel == 5)){ + vo.setEvaluateButtonStatus(0); + } + }else{ + if(vo.getReportType() == 5){ + vo.setEvaluateButtonStatus(0); + } + } + } + } + + + /** + * 工单详情 + * + * @param id + * @return + */ + @Override + public ComplaintVO detail(Long id, LoginUserInfoVO loginUserInfoVO) { + Optional<SystemUser> systemUserByPhone = systemUserService.getSystemUserAdminByPhone(loginUserInfoVO.getPhone()); + String targetId = ""; + Integer accountLevel = 5; + //上级 + if (systemUserByPhone.isPresent()) { + SystemUser systemUser = systemUserByPhone.get(); + accountLevel = systemUser.getAccountLevel(); switch (accountLevel) { case 1: //市级 @@ -137,25 +386,17 @@ //社区 targetId = systemUser.getCommunityId().toString(); break; + case 5: + //党员 + PartyMember partyMember = partyMemberService.getPartyMemberByPhone(loginUserInfoVO.getPhone()); + targetId = partyMember.getId().toString(); + break; } - isSuperior = 1; } else { - //党员 - targetId = loginUserInfoVO.getUserId().toString(); + //党员 + PartyMember partyMember = partyMemberService.getPartyMemberByPhone(loginUserInfoVO.getPhone()); + targetId = partyMember.getId().toString(); } - //查询对应诉求 - query.setUserId(loginUserInfoVO.getUserId());//当前登录用户id - page = baseMapper.selectComplaintPage(page, query, targetId,isSuperior); - return page; - } - - /** - * 工单详情 - * @param id - * @return - */ - @Override - public ComplaintVO detail(Long id) { ComplaintVO detail = baseMapper.getDetail(id); if (detail.getStatus().equals(0)) { List<ComplaintFlow> list = complaintFlowService.lambdaQuery().eq(ComplaintFlow::getComplaintId, id).orderByAsc(ComplaintFlow::getCreateTime).list(); @@ -165,6 +406,31 @@ 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); + } + } + } return detail; } @@ -199,8 +465,10 @@ complaint.setCompletionTime(new Date()); this.updateById(complaint); } + /** * 办理进度列表 + * * @param complaintId * @return */ @@ -215,7 +483,6 @@ @Transactional(rollbackFor = Exception.class) public void saveReport(ComplaintReportDTO dto, LoginUserInfoVO loginUserInfoVO) { String phone = loginUserInfoVO.getPhone(); - SystemUser adminUser = systemUserService.getOne(new LambdaQueryWrapper<SystemUser>() .eq(SystemUser::getPhone, phone) .eq(SystemUser::getIsAdmin, 1) @@ -226,7 +493,7 @@ int reportType; if (adminUser == null) { superiorId = loginUserInfoVO.getCommunityId(); - if (Objects.isNull(superiorId)){ + if (Objects.isNull(superiorId)) { throw new ServiceException("上报失败,请绑定社区"); } reportType = ReportTypeEnum.COMMUNITY.getCode(); @@ -244,6 +511,8 @@ superiorId = Long.parseLong(adminUser.getDistrictsCode()); } else if (accountLevel == ReportTypeEnum.DISTRICT.getCode()) { superiorId = 510400L; // 攀枝花市 + } else if(accountLevel == ReportTypeEnum.PARTY.getCode()){ + superiorId = adminUser.getCommunityId(); } else { // 处理未预期的账号等级 throw new ServiceException("未知的账号等级"); @@ -251,17 +520,33 @@ } Complaint complaint = getById(dto.getComplaintId()); - complaint.setReportType(reportType); - complaint.setSuperiorId(superiorId); + if (complaint.getStatus() != 0) { + complaint.setStatus(0); + } updateById(complaint); // 标记最新 complaintAuditRecordService.update(new LambdaUpdateWrapper<ComplaintAuditRecord>() .eq(ComplaintAuditRecord::getComplaintId, dto.getComplaintId()) - .set(ComplaintAuditRecord::getLatestFlag,false)); + .set(ComplaintAuditRecord::getLatestFlag, false)); // 添加审核记录 - complaintAuditRecordService.createComplaintAuditRecord(dto.getComplaintId(), 2, dto.getComment(), loginUserInfoVO,adminUser); + int count = complaintAuditRecordService.count(new LambdaQueryWrapper<ComplaintAuditRecord>().eq(ComplaintAuditRecord::getComplaintId, complaint.getId())); + ComplaintAuditRecord complaintAuditRecord = new ComplaintAuditRecord(); + complaintAuditRecord.setComplaintId(complaint.getId()); + complaintAuditRecord.setLatestFlag(true); + complaintAuditRecord.setAuditType(2); + complaintAuditRecord.setAuditStatus(0); + complaintAuditRecord.setCreateBy(loginUserInfoVO.getUserId()); + complaintAuditRecord.setCreateTime(new Date()); + complaintAuditRecord.setUpdateBy(loginUserInfoVO.getUserId()); + complaintAuditRecord.setUpdateTime(new Date()); + complaintAuditRecord.setReporter(loginUserInfoVO.getNickName()); + complaintAuditRecord.setReportType(reportType); + complaintAuditRecord.setSuperiorId(superiorId); + complaintAuditRecord.setComment(dto.getComment()); + complaintAuditRecord.setSort(count + 1); + complaintAuditRecordService.save(complaintAuditRecord); } @Override @@ -278,85 +563,93 @@ throw new ServiceException("无权下派"); } - - long superiorId; int accountLevel = adminUser.getAccountLevel(); // 改为基本类型 if (accountLevel == 4) { throw new ServiceException("社区账号,无法下派!"); } + accountLevel++; - // 使用基本类型比较并补充默认分支 - if (accountLevel == ReportTypeEnum.STREET.getCode()) { - superiorId = adminUser.getCommunityId().longValue(); - } else if (accountLevel == ReportTypeEnum.DISTRICT.getCode()) { - superiorId = Long.parseLong(adminUser.getStreetId()); - } else if (accountLevel == ReportTypeEnum.CITY.getCode()) { - superiorId = Long.parseLong(adminUser.getDistrictsCode()); - } else { - // 处理未预期的账号等级 - throw new ServiceException("未知的账号等级"); - } - - Long superiorOrgId; Complaint complaint = getById(dto.getComplaintId()); - superiorOrgId = complaint.getSuperiorId(); - complaint.setReportType(accountLevel + 1); - complaint.setSuperiorId(superiorId); 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(); // 添加流转记录 - complaintFlowService.createFlow(dto.getComplaintId(), superiorOrgId, accountLevel, 1, loginUserInfoVO.getUserId()); + complaintFlowService.createFlow(complaintAuditRecord, 1,loginUserInfoVO.getUserId()); + + // 标记最新 + complaintAuditRecordService.update(new LambdaUpdateWrapper<ComplaintAuditRecord>() + .eq(ComplaintAuditRecord::getComplaintId, dto.getComplaintId()) + .set(ComplaintAuditRecord::getLatestFlag, false)); + int count = complaintAuditRecordService.count(new LambdaQueryWrapper<ComplaintAuditRecord>().eq(ComplaintAuditRecord::getComplaintId, complaint.getId())); + ComplaintAuditRecord record = new ComplaintAuditRecord(); + record.setComplaintId(complaint.getId()); + record.setLatestFlag(true); + record.setAuditType(3); + record.setAuditStatus(1); + record.setCreateBy(loginUserInfoVO.getUserId()); + record.setCreateTime(new Date(System.currentTimeMillis())); + record.setUpdateBy(loginUserInfoVO.getUserId()); + record.setUpdateTime(new Date(System.currentTimeMillis())); + record.setReporter(loginUserInfoVO.getNickName()); + record.setReportType(accountLevel); + record.setSuperiorId(dto.getDispatchId()); + record.setSort(count + 1); + complaintAuditRecordService.save(record); } @Override @Transactional(rollbackFor = Exception.class) public void reportAudit(ComplaintReporAuditDTO complaintReporAuditDTO, LoginUserInfoVO loginUserInfoVO) { - Optional<SystemUser> systemUserByPhone = systemUserService.getSystemUserByPhone(loginUserInfoVO.getPhone()); + Optional<SystemUser> systemUserByPhone = systemUserService.getSystemUserAdminByPhone(loginUserInfoVO.getPhone()); if (!systemUserByPhone.isPresent()) { throw new ServiceException("无权审核"); } + + SystemUser systemUser = systemUserByPhone.get(); + Long superiorId = 0L; + switch (systemUser.getAccountLevel()) { + case 1: + superiorId = 510400L;//默认市级 + break; + case 2: + superiorId = Long.parseLong(systemUser.getDistrictsCode()); + break; + case 3: + superiorId = Long.parseLong(systemUser.getStreetId()); + break; + case 4: + superiorId = systemUser.getCommunityId(); + break; + } + //查询上报审核记录 - ComplaintAuditRecord complaintAuditRecord = complaintAuditRecordService.lambdaQuery().eq(ComplaintAuditRecord::getComplaintId, complaintReporAuditDTO.getId()) + ComplaintAuditRecord complaintAuditRecord = complaintAuditRecordService.lambdaQuery() + .eq(ComplaintAuditRecord::getComplaintId, complaintReporAuditDTO.getId()) .eq(ComplaintAuditRecord::getAuditType, 2) .eq(ComplaintAuditRecord::getLatestFlag, true) + .eq(ComplaintAuditRecord::getReportType, systemUser.getAccountLevel()) + .eq(ComplaintAuditRecord::getSuperiorId, superiorId) .last("LIMIT 1").one(); if (Objects.isNull(complaintAuditRecord)) { throw new ServiceException("上报申请记录不存在"); } - //查询待审核诉求 - complaintAuditRecordService.audit(complaintAuditRecord, loginUserInfoVO.getUserId(), - complaintReporAuditDTO.getAuditResult(), complaintReporAuditDTO.getRejectReason()); - - // 添加流转记录 - Complaint complaint = getById(complaintAuditRecord.getComplaintId()); - - Long superiorId = null; - if (Objects.nonNull(complaint) && complaintReporAuditDTO.getAuditResult().equals(1)) { - superiorId = complaint.getCreateBy(); - if (Objects.nonNull(complaint.getSuperiorId())) { - superiorId = complaint.getSuperiorId(); - } - complaintFlowService.createFlow(complaintAuditRecord.getComplaintId(), superiorId,complaint.getReportType(),0, loginUserInfoVO.getUserId()); - //审核通过后,将诉求转移给上级 - if (complaintAuditRecord.getAuditType().equals(2) && complaintAuditRecord.getAuditStatus().equals(1)){ - SystemUser systemUser = systemUserByPhone.get(); - switch (systemUser.getAccountLevel()) { - case 1: - superiorId = 510400L;//默认市级 - break; - case 2: - superiorId = Long.parseLong(systemUser.getDistrictsCode()); - break; - case 3: - superiorId = Long.parseLong(systemUser.getStreetId()); - break; - case 4: - superiorId = systemUser.getCommunityId(); - break; - } - } - complaint.setSuperiorId(superiorId); - updateById(complaint ); + if (complaintReporAuditDTO.getAuditResult().equals(1)) { + complaintAuditRecord.setAuditStatus(1); + complaintAuditRecord.setAuditorId(loginUserInfoVO.getUserId()); + complaintAuditRecordService.updateById(complaintAuditRecord); + //创建流程 + complaintFlowService.createFlow(complaintAuditRecord ,0, loginUserInfoVO.getUserId()); + } else { + complaintAuditRecord.setRejectReason(complaintReporAuditDTO.getRejectReason()); + complaintAuditRecord.setAuditStatus(2); + complaintAuditRecord.setAuditorId(loginUserInfoVO.getUserId()); + complaintAuditRecordService.updateById(complaintAuditRecord); } } @@ -364,25 +657,21 @@ @Override @Transactional(rollbackFor = Exception.class) public void saveDelay(ComplaintDelayDTO dto, LoginUserInfoVO loginUserInfoVO) { - // 标记最新 - complaintAuditRecordService.update(new LambdaUpdateWrapper<ComplaintAuditRecord>() - .eq(ComplaintAuditRecord::getComplaintId, dto.getComplaintId()) - .set(ComplaintAuditRecord::getLatestFlag,false)); - SystemUser systemUser = systemUserService.getSystemUserByPhone(loginUserInfoVO.getPhone()).orElse(null); + SystemUser systemUser = systemUserService.getSystemUserAdminByPhone(loginUserInfoVO.getPhone()).orElse(null); Long superiorId; int reportType; if (systemUser == null) { superiorId = loginUserInfoVO.getCommunityId(); - if (Objects.isNull(superiorId)){ - throw new ServiceException("上报失败,请绑定社区"); + if (Objects.isNull(superiorId)) { + throw new ServiceException("延期申请失败,请绑定社区"); } reportType = ReportTypeEnum.COMMUNITY.getCode(); } else { int accountLevel = systemUser.getAccountLevel(); // 改为基本类型 if (accountLevel == 1) { - throw new ServiceException("市级账号,无法上报!"); + throw new ServiceException("市级账号,无法延期申请!"); } - reportType = accountLevel + 1; + reportType = accountLevel - 1; // 使用基本类型比较并补充默认分支 if (accountLevel == ReportTypeEnum.COMMUNITY.getCode()) { @@ -391,39 +680,86 @@ superiorId = Long.parseLong(systemUser.getDistrictsCode()); } else if (accountLevel == ReportTypeEnum.DISTRICT.getCode()) { superiorId = 510400L; // 攀枝花市 + } else if (accountLevel == ReportTypeEnum.PARTY.getCode()) { + superiorId = systemUser.getCommunityId(); } else { // 处理未预期的账号等级 throw new ServiceException("未知的账号等级"); } } - Complaint complaint = getById(dto.getComplaintId()); - complaint.setReportType(reportType); - complaint.setSuperiorId(superiorId); - updateById(complaint); - // 添加审核记录 - complaintAuditRecordService.createComplaintAuditRecord(dto.getComplaintId(), 1, dto.getComment(), loginUserInfoVO, systemUser); + // 清除最新记录 + complaintAuditRecordService.update(new LambdaUpdateWrapper<ComplaintAuditRecord>() + .eq(ComplaintAuditRecord::getComplaintId, dto.getComplaintId()) + .set(ComplaintAuditRecord::getLatestFlag, false)); + int count = complaintAuditRecordService.count(new LambdaQueryWrapper<ComplaintAuditRecord>().eq(ComplaintAuditRecord::getComplaintId, dto.getComplaintId())); + ComplaintAuditRecord record1 = new ComplaintAuditRecord(); + record1.setComplaintId(dto.getComplaintId()); + record1.setLatestFlag(true); + record1.setAuditType(1); + record1.setAuditStatus(0); + record1.setCreateBy(loginUserInfoVO.getUserId()); + record1.setCreateTime(new Date(System.currentTimeMillis())); + record1.setUpdateBy(loginUserInfoVO.getUserId()); + record1.setUpdateTime(new Date(System.currentTimeMillis())); + record1.setReporter(loginUserInfoVO.getNickName()); + record1.setReportType(reportType); + record1.setSuperiorId(superiorId); + record1.setSort(count + 1); + record1.setComment(dto.getComment()); + complaintAuditRecordService.save(record1); } @Override - public void delayAudit(ComplaintDelayAuditDTO complaintDelayAuditDTO, LoginUserInfoVO loginUserInfoVO) { - //查询待审核诉求 - ComplaintAuditRecord complaintAuditRecord = complaintAuditRecordService.lambdaQuery().eq(ComplaintAuditRecord::getComplaintId, complaintDelayAuditDTO.getComplaintId()) + public void delayAudit(ComplaintDelayAuditDTO dto, LoginUserInfoVO loginUserInfoVO) { + SystemUser systemUser = systemUserService.getSystemUserAdminByPhone(loginUserInfoVO.getPhone()).orElse(null); + int accountLevel = systemUser.getAccountLevel(); // 改为基本类型 + Long superiorId; + // 使用基本类型比较并补充默认分支 + if (accountLevel == ReportTypeEnum.COMMUNITY.getCode()) { + superiorId = systemUser.getCommunityId(); + } else if (accountLevel == ReportTypeEnum.STREET.getCode()) { + superiorId = Long.parseLong(systemUser.getStreetId()); + } else if (accountLevel == ReportTypeEnum.DISTRICT.getCode()) { + superiorId = Long.parseLong(systemUser.getDistrictsCode()); + } else if (accountLevel == ReportTypeEnum.CITY.getCode()) { + superiorId = 510400L; + } else { + // 处理未预期的账号等级 + throw new ServiceException("未知的账号等级"); + } + + + ComplaintAuditRecord complaintAuditRecord = complaintAuditRecordService.getOne(new LambdaQueryWrapper<ComplaintAuditRecord>() .eq(ComplaintAuditRecord::getAuditType, 1) + .eq(ComplaintAuditRecord::getLatestFlag, 1) .eq(ComplaintAuditRecord::getAuditStatus, 0) - .eq(ComplaintAuditRecord::getLatestFlag, true) - .last("LIMIT 1").one(); + .ne(ComplaintAuditRecord::getSuperiorId, superiorId) + .eq(ComplaintAuditRecord::getReportType, accountLevel) + .eq(ComplaintAuditRecord::getComplaintId, dto.getComplaintId()) + .last("LIMIT 1")); + + if (Objects.isNull(complaintAuditRecord)) { throw new ServiceException("诉求延期申请不存在"); } - complaintAuditRecordService.audit(complaintAuditRecord, loginUserInfoVO.getUserId(), - complaintDelayAuditDTO.getAuditResult(), complaintDelayAuditDTO.getRejectReason()); //审核通过后,设置诉求延期 - if (complaintAuditRecord.getAuditType().equals(1) && complaintAuditRecord.getAuditStatus().equals(1)){ + if (complaintAuditRecord.getAuditType().equals(1) && complaintAuditRecord.getAuditStatus().equals(0) && dto.getAuditResult().equals(1)) { Complaint complaint = getById(complaintAuditRecord.getComplaintId()); complaint.setStatus(1); updateById(complaint); + + complaintAuditRecord.setAuditStatus(1); + complaintAuditRecord.setAuditorId(loginUserInfoVO.getUserId()); + complaintAuditRecordService.updateById(complaintAuditRecord); + } + //审核不通过 + if(complaintAuditRecord.getAuditType().equals(1) && complaintAuditRecord.getAuditStatus().equals(0) && dto.getAuditResult().equals(2)){ + complaintAuditRecord.setRejectReason(dto.getRejectReason()); + complaintAuditRecord.setAuditStatus(2); + complaintAuditRecord.setAuditorId(loginUserInfoVO.getUserId()); + complaintAuditRecordService.updateById(complaintAuditRecord); } } @@ -448,18 +784,20 @@ // 使用基本类型比较并补充默认分支 List<DispatchVO> dispatchVOList = new ArrayList<>(); if (accountLevel == ReportTypeEnum.STREET.getCode()) { - List<ComAct> list = comActService.list(); + String streetId = adminUser.getStreetId(); + List<ComAct> list = comActService.list(new LambdaQueryWrapper<ComAct>().eq(ComAct::getStreetId, streetId).eq(ComAct::getState, 0)); for (ComAct comAct : list) { DispatchVO dispatchVO = new DispatchVO(); - dispatchVO.setId(comAct.getCommunityId()); + dispatchVO.setId(comAct.getCommunityId().toString()); dispatchVO.setName(comAct.getName()); dispatchVOList.add(dispatchVO); } } else if (accountLevel == ReportTypeEnum.DISTRICT.getCode()) { - List<ComStreet> list = comStreetService.list(); + String districtsCode = adminUser.getDistrictsCode(); + List<ComStreet> list = comStreetService.list(new LambdaQueryWrapper<ComStreet>().eq(ComStreet::getAreaCode, districtsCode)); for (ComStreet street : list) { DispatchVO dispatchVO = new DispatchVO(); - dispatchVO.setId(Long.valueOf(street.getStreetId())); + dispatchVO.setId(street.getStreetId().toString()); dispatchVO.setName(street.getName()); dispatchVOList.add(dispatchVO); } @@ -468,7 +806,7 @@ .eq(BcRegion::getHierarchyOrder, 3).eq(BcRegion::getParentId, 510400));//获取攀枝花市下的区县 for (BcRegion region : list) { DispatchVO dispatchVO = new DispatchVO(); - dispatchVO.setId(Long.valueOf(region.getRegionCode())); + dispatchVO.setId(region.getRegionCode()); dispatchVO.setName(region.getRegionName()); dispatchVOList.add(dispatchVO); } @@ -478,15 +816,17 @@ } return dispatchVOList; } + /** * 获取待办诉求 + * * @param basePage * @param loginUserInfo * @return */ @Override public Page<ComplaintTodoVO> getTodoList(BasePage basePage, LoginUserInfoVO loginUserInfo) { - Optional<SystemUser> systemUserByPhone = systemUserService.getSystemUserByPhone(loginUserInfo.getPhone()); + Optional<SystemUser> systemUserByPhone = systemUserService.getSystemUserAdminByPhone(loginUserInfo.getPhone()); String targetId = ""; int isSuperior = 0; //上级 @@ -516,11 +856,13 @@ //党员 targetId = loginUserInfo.getUserId().toString(); } - Page<ComplaintTodoVO> page = baseMapper.getTodoList(new Page<>(basePage.getPageNum(), basePage.getPageSize()), targetId,isSuperior); + Page<ComplaintTodoVO> page = baseMapper.getTodoList(new Page<>(basePage.getPageNum(), basePage.getPageSize()), targetId, isSuperior); return page; } + /** * 延期情况说明 + * * @param complaintId * @return */ @@ -531,5 +873,16 @@ .eq(ComplaintAuditRecord::getLatestFlag, true) .last("LIMIT 1").one(); } + + + /** + * 获取超时未评价的数据 + * @return + */ + @Override + public List<Complaint> getTimeoutAndNotComment() { + return this.baseMapper.getTimeoutAndNotComment(); + } + } -- Gitblit v1.7.1