From 039abee6b27058ca46b1e1e82aa0b5407a5dad44 Mon Sep 17 00:00:00 2001 From: liujie <1793218484@qq.com> Date: 星期一, 28 七月 2025 15:25:26 +0800 Subject: [PATCH] 优化 和修改bug --- springcloud_k8s_panzhihuazhihuishequ/service_westcommittee/src/main/java/com/panzhihua/westcommittee/service/impl/ComplaintServiceImpl.java | 823 +++++++++++++++++++++++++++++++++++++++++++++------------- 1 files changed, 640 insertions(+), 183 deletions(-) diff --git a/springcloud_k8s_panzhihuazhihuishequ/service_westcommittee/src/main/java/com/panzhihua/westcommittee/service/impl/ComplaintServiceImpl.java b/springcloud_k8s_panzhihuazhihuishequ/service_westcommittee/src/main/java/com/panzhihua/westcommittee/service/impl/ComplaintServiceImpl.java index 8dc475b..33eaa84 100644 --- a/springcloud_k8s_panzhihuazhihuishequ/service_westcommittee/src/main/java/com/panzhihua/westcommittee/service/impl/ComplaintServiceImpl.java +++ b/springcloud_k8s_panzhihuazhihuishequ/service_westcommittee/src/main/java/com/panzhihua/westcommittee/service/impl/ComplaintServiceImpl.java @@ -11,7 +11,7 @@ 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.model.vos.west.SystemUserVo; import com.panzhihua.common.redis.RedisUtils; import com.panzhihua.common.utlis.DateUtils; import com.panzhihua.common.utlis.StringUtils; @@ -27,9 +27,8 @@ import com.panzhihua.westcommittee.model.query.ComplaintQuery; import com.panzhihua.westcommittee.model.vo.*; import com.panzhihua.westcommittee.service.*; -import com.panzhihua.westcommittee.warpper.IdentityInformation; -import com.panzhihua.westcommittee.warpper.MgtComplaintQuery; -import com.panzhihua.westcommittee.warpper.PermissionsVO; +import com.panzhihua.westcommittee.utils.AliSmsUtil; +import com.panzhihua.westcommittee.warpper.*; import jodd.util.StringUtil; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; @@ -80,10 +79,14 @@ private final IPartyMemberService partyMemberService; private final IdentityInformationService identityInformationService; private final IDepartmentService departmentService; + private final WestPopUpService westPopUpService; + private final RedisUtils redisUtils; @Override - public void saveComplaint(Complaint complaint, LoginUserInfoVO loginUserInfoVO) { + public HashMap<String, String> saveComplaint(Complaint complaint, LoginUserInfoVO loginUserInfoVO) { + HashMap<String, String> map = new HashMap<>(); + String timeStr = null; // 获取当前日期(年月日) String datePrefix = new SimpleDateFormat("yyyyMMdd").format(new Date()); @@ -113,22 +116,15 @@ SystemUser systemUser = identityInformationVO.getSystemUser(); Integer identity = identityInformationVO.getIdentity(); if (identity == 2) { + loginUserInfoVO.setUserId(Long.valueOf(systemUser.getId())); accountLevel = systemUser.getAccountLevel(); switch (accountLevel) { - case 1: - //市级 - complaint.setCityCode(510400); - complaint.setReportUserName(systemUser.getName()); - complaint.setReportUserPhone(systemUser.getPhone()); - break; case 2: //区县级 complaint.setCityCode(510400); complaint.setDistrictsCode(Integer.valueOf(systemUser.getDistrictsCode())); complaint.setReportUserName(systemUser.getName()); complaint.setReportUserPhone(systemUser.getPhone()); - - complaint.setSuperiorId(Long.valueOf(systemUser.getDistrictsCode())); break; case 3: @@ -163,7 +159,7 @@ complaint.setReportUserName(partyMember.getName()); complaint.setReportUserPhone(partyMember.getPhone()); - accountLevel=4; + accountLevel = 4; complaint.setSuperiorId(systemUser.getCommunityId()); break; } @@ -177,15 +173,37 @@ // } } else { PartyMember partyMember = partyMemberService.getPartyMemberByPhone(loginUserInfoVO.getPhone()); - //党员 complaint.setCityCode(510400); - complaint.setDistrictsCode(Integer.valueOf(partyMember.getDistrictsCode())); - complaint.setStreetId(Long.valueOf(partyMember.getStreetId())); - complaint.setCommunityId(partyMember.getCommunityId()); - complaint.setPartyMemberId(partyMember.getId()); - complaint.setReportUserName(partyMember.getName()); - complaint.setReportUserPhone(partyMember.getPhone()); - complaint.setSuperiorId( partyMember.getCommunityId()); + if (partyMember != null) { + //党员 + complaint.setDistrictsCode(Integer.valueOf(partyMember.getDistrictsCode())); + complaint.setStreetId(Long.valueOf(partyMember.getStreetId())); + complaint.setCommunityId(partyMember.getCommunityId()); + complaint.setPartyMemberId(partyMember.getId()); + complaint.setReportUserName(partyMember.getName()); + complaint.setReportUserPhone(partyMember.getPhone()); + complaint.setSuperiorId(partyMember.getCommunityId()); + } else { + complaint.setDistrictsCode(Integer.valueOf(loginUserInfoVO.getAreaCode())); + complaint.setStreetId(loginUserInfoVO.getStreetId()); + complaint.setCommunityId(loginUserInfoVO.getCommunityId()); + complaint.setReportUserName(loginUserInfoVO.getName()); + complaint.setReportUserPhone(loginUserInfoVO.getPhone()); + complaint.setSuperiorId(loginUserInfoVO.getCommunityId()); + + + ComAct byId = comActService.getById(loginUserInfoVO.getCommunityId()); + String name = byId.getName(); + WestPopUp one = westPopUpService.getOne(new LambdaQueryWrapper<WestPopUp>().eq(WestPopUp::getName, name)); + + if(one!=null){ + map.put("name", one.getDeptName()); + map.put("phone", one.getPhone()); + } + + + } + // 添加处理人 // SystemUser one = systemUserService.getOne(new LambdaQueryWrapper<SystemUser>().eq(SystemUser::getAccountLevel, 4).eq(SystemUser::getIsDeptAdmin, 1).eq(SystemUser::getCommunityId, partyMember.getCommunityId()).ne(SystemUser::getStatus, 3)); @@ -212,9 +230,15 @@ if (Objects.isNull(config)) { throw new ServiceException("工单事项未配置,请联系管理员"); } - complaint.setClosingTime(new Date(System.currentTimeMillis() + config.getDemandProcessingTime() * 24 * 60 * 60 * 1000)); + complaint.setNowLevelTime(new Date()); + complaint.setNowLevelSms(0); // 保存诉求记录 save(complaint); + + + + + return map; } @Override @@ -242,6 +266,7 @@ saveResult(complaintCompletionDTO, loginUserInfo); } + @Override public Page<ComplaintVO> complaintList(ComplaintQuery query, LoginUserInfoVO loginUserInfoVO) { @@ -259,8 +284,9 @@ SystemUser systemUser; //上级 if (systemUserByPhone.isPresent() && null != identity && identity == 2) { - systemUser= systemUserByPhone.get(); + systemUser = systemUserByPhone.get(); accountLevel = systemUser.getAccountLevel(); + query.setUserId(Long.valueOf(systemUser.getId())); switch (accountLevel) { case 2: //区县级 @@ -284,42 +310,126 @@ systemUser = null; //党员 PartyMember partyMember = partyMemberService.getPartyMemberByPhone(loginUserInfoVO.getPhone()); - targetId = partyMember.getCommunityId(); + if (partyMember != null) { + targetId = partyMember.getCommunityId(); + } else { + targetId = loginUserInfoVO.getCommunityId(); + } } //查询对应诉求 //page = baseMapper.selectComplaintPage(page, query, targetId, isSuperior); // 党员只看自己上报的 - if(accountLevel==5){ - page = baseMapper.selectComplaintPage2(page, query, accountLevel, targetId); - }else if(accountLevel==2){ + if (accountLevel == 5) { + page = baseMapper.selectComplaintPage2(page, query, accountLevel, targetId); + } else if (accountLevel == 2) { // 西区单位 如果是西区单位,则只看自己上报的 - if(systemUser.getSystemRoleId()==1){ + if (systemUser.getSystemRoleId() == 1 || systemUser.getSystemRoleId() == 2) { // 是管理员 看所有的 - page = baseMapper.selectComplaintPage3(page, query, accountLevel, targetId); - }else { + page = baseMapper.selectComplaintPage3(page, query, accountLevel, targetId, systemUser.getSystemRoleId()); + } else { // 不是管理员 看到指派给我的单位的诉求 - page = baseMapper.selectComplaintPage4(page, query, systemUser.getOneDepartmentId()); + page = baseMapper.selectComplaintPage4(page, query, systemUser.getOneDepartmentId()); } - }else if(accountLevel==3){ + } else if (accountLevel == 3) { // 街道 1 - if(systemUser.getSystemRoleId()==1){ + if (systemUser.getSystemRoleId() == 1 || systemUser.getSystemRoleId() == 2) { + // 获取这个街道所管的社区id + List<Long> communityIds = comActService.list(new LambdaQueryWrapper<ComAct>().eq(ComAct::getStreetId, systemUser.getStreetId())).stream().map(ComAct::getCommunityId).collect(Collectors.toList()); // 是管理员 可以看到下派来的 也可以看到上派待审核的 - page = baseMapper.selectComplaintPage5(page, query,systemUser.getStreetId(),null); - }else { + page = baseMapper.selectComplaintPage5(page, query, systemUser.getStreetId(), communityIds, systemUser.getSystemRoleId()); + } else { // 不是管理员 看指派给我的 - page = baseMapper.selectComplaintPage4(page, query, systemUser.getOneDepartmentId()); + page = baseMapper.selectComplaintPage4(page, query, systemUser.getOneDepartmentId()); } - }else if(accountLevel==4){ + } else if (accountLevel == 4) { // 社区 - if(systemUser.getSystemRoleId()==1){ + if (systemUser.getSystemRoleId() == 1 || systemUser.getSystemRoleId() == 2) { // 是管理员 - page = baseMapper.selectComplaintPage6(page, query,systemUser.getCommunityId(),null); - }else { + page = baseMapper.selectComplaintPage6(page, query, systemUser.getCommunityId(), null, systemUser.getSystemRoleId()); + } else { // 不是管理员 看到负责社区的所有诉求 和 上级下派来的诉求 - page = baseMapper.selectComplaintPage4(page, query, systemUser.getOneDepartmentId()); + page = baseMapper.selectComplaintPage4(page, query, systemUser.getOneDepartmentId()); } } + + + Date date = new Date(); + WorkOrderItemConfig config = workOrderItemConfigService.getById(1); + for (ComplaintVO record : page.getRecords()) { + + // 处理页面颜色展示和倒计时 + Date nowLevelTime = record.getNowLevelTime(); + if (record.getNowLevel() == 2) { + Long HandlingTime = config.getDistrictHandlingTime().longValue(); + Long DeadlineReminder = config.getDistrictDeadlineReminder().longValue(); + // 判断是超时 还是 临期 + if (nowLevelTime.getTime() + HandlingTime * 24 * 60 * 60 * 1000 < date.getTime()) { + record.setRemindStatus(2); + } else if (nowLevelTime.getTime() + DeadlineReminder * 24 * 60 * 60 * 1000 < date.getTime()) { + record.setRemindStatus(1); + } + long l = nowLevelTime.getTime() + HandlingTime * 24 * 60 * 60 * 1000 - date.getTime(); + double days = (double) l / (24 * 60 * 60 * 1000); // 毫秒转天数 + BigDecimal result = new BigDecimal(days).setScale(1, RoundingMode.HALF_UP); // 保留1位小数 + record.setRemindTime(result.doubleValue()); + } else if (record.getNowLevel() == 3) { + Long HandlingTime = config.getStreetHandlingTime().longValue(); + Long DeadlineReminder = config.getStreetDeadlineReminder().longValue(); + // 判断是超时 还是 临期 + if (nowLevelTime.getTime() + HandlingTime * 24 * 60 * 60 * 1000 < date.getTime()) { + record.setRemindStatus(2); + } else if (nowLevelTime.getTime() + DeadlineReminder * 24 * 60 * 60 * 1000 < date.getTime()) { + record.setRemindStatus(1); + } + long l = nowLevelTime.getTime() + HandlingTime * 24 * 60 * 60 * 1000 - date.getTime(); + double days = (double) l / (24 * 60 * 60 * 1000); // 毫秒转天数 + BigDecimal result = new BigDecimal(days).setScale(1, RoundingMode.HALF_UP); // 保留1位小数 + record.setRemindTime(result.doubleValue()); + } else if (record.getNowLevel() == 4) { + Long HandlingTime = config.getCommunityHandlingTime().longValue(); + Long DeadlineReminder = config.getCommunityDeadlineReminder().longValue(); + // 判断是超时 还是 临期 + if (nowLevelTime.getTime() + HandlingTime * 24 * 60 * 60 * 1000 < date.getTime()) { + record.setRemindStatus(2); + } else if (nowLevelTime.getTime() + DeadlineReminder * 24 * 60 * 60 * 1000 < date.getTime()) { + record.setRemindStatus(1); + } + long l = nowLevelTime.getTime() + HandlingTime * 24 * 60 * 60 * 1000 - date.getTime(); + double days = (double) l / (24 * 60 * 60 * 1000); // 毫秒转天数 + BigDecimal result = new BigDecimal(days).setScale(1, RoundingMode.HALF_UP); // 保留1位小数 + record.setRemindTime(result.doubleValue()); + } + + + int count = complaintCommentService.count(new LambdaQueryWrapper<ComplaintComment>().eq(ComplaintComment::getComplaintId, record.getId())); + if (count > 0) { + record.setEvaluateButtonStatus(1); + } else { + if(record.getStatus()==3){ + record.setEvaluateButtonStatus(0); + }else { + record.setEvaluateButtonStatus(1); + } +// 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; } @@ -398,7 +508,7 @@ .last(" limit 0, 1")); if (null != one1) { //非党员用户,必须是管理员有权限 - if (identity == 2 && systemUser1.getAccountLevel().compareTo(one1.getReportType()) == 0 && systemUser1.getAccountLevel()!= 5) { + if (identity == 2 && systemUser1.getAccountLevel().compareTo(one1.getReportType()) == 0 && systemUser1.getAccountLevel() != 5) { vo.setListControlsButtonStatus(0); } /*if (systemUserByPhone.isPresent()) { @@ -430,7 +540,7 @@ } }*/ //当前身份是管理员 - if (2 == identity && systemUser1.getAccountLevel().compareTo(vo.getReportType()) == 0 && (systemUser1.getAccountLevel()!= 5)) { + if (2 == identity && systemUser1.getAccountLevel().compareTo(vo.getReportType()) == 0 && (systemUser1.getAccountLevel() != 5)) { vo.setListControlsButtonStatus(0); } //如果当前身份是党员 @@ -469,7 +579,7 @@ String targetId = ""; Integer accountLevel = 5; //获取当前身份,1=党员,2=管理员 - accountLevel =systemUser1.getAccountLevel(); + accountLevel = systemUser1.getAccountLevel(); switch (accountLevel) { case 1: //市级 @@ -524,7 +634,7 @@ } }*/ //当前不是党员身份,需要是管理员才有权限 - if (2 == identity && systemUser1.getAccountLevel().compareTo(vo.getReportType()) == 0 && systemUser1.getAccountLevel()!= 5) { + if (2 == identity && systemUser1.getAccountLevel().compareTo(vo.getReportType()) == 0 && systemUser1.getAccountLevel() != 5) { vo.setEvaluateButtonStatus(0); } //当前是党员身份,只有是以党员身份提交的数据才有权限 @@ -590,55 +700,87 @@ } else { //党员 PartyMember partyMember = partyMemberService.getPartyMemberByPhone(loginUserInfoVO.getPhone()); - targetId = partyMember.getId().toString(); + if (partyMember != null) { + targetId = partyMember.getId().toString(); + } else { + targetId = loginUserInfoVO.getUserId().toString(); + } + } // 更新状态 此时status是表中的状态 未做变动 // 如果是区级 - if(systemUser!=null) { + 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){ - detail.setStatus(-1); - } - if (systemUser.getSystemRoleId() == 0) { - // 查是否是当前层级处理 不是则都是正在办理 - if (detail.getNowLevel() != 4 && detail.getStatus() != 3 && detail.getStatus() != 8) { + if(detail.getStatus()!=5) { + if (detail.getStatus() != 3 && detail.getStatus() != 8 && detail.getNowLevel() == 2 && detail.getAssignStatus() == 0 && ((one != null && one.getAuditStatus() == 1) || (one != null && one.getAuditStatus() == 3) || one == null)) { + detail.setStatus(-1); + } else if (systemUser.getSystemRoleId() == 0) { + // 查是否是当前层级处理 不是则都是正在办理 + if (detail.getNowLevel() != 4 && detail.getStatus() != 3 && detail.getStatus() != 8) { + detail.setStatus(0); + } + } else if (detail.getStatus() != 3 && detail.getStatus() != 8 && detail.getFirstStatus() == 0 && detail.getNowLevel() == 2) { + detail.setStatus(5); + } else if (detail.getStatus() == 3 || detail.getStatus() == 8) { + detail.setStatus(detail.getStatus()); + } else { detail.setStatus(0); } + } + } if (systemUser.getAccountLevel() == 3) { - if(detail.getNowLevel()==3 && detail.getAssignStatus()==0){ - detail.setStatus(-1); - } - if (systemUser.getSystemRoleId() == 0) { - // 查是否是当前层级处理 不是则都是正在办理 - if (detail.getNowLevel() != 3 && detail.getStatus() != 3 && detail.getStatus() != 8) { + if(detail.getStatus()!=5) { + if (detail.getStatus() != 3 && detail.getStatus() != 8 && detail.getNowLevel() == 3 && detail.getAssignStatus() == 0 && ((one != null && one.getAuditStatus() == 1) || (one != null && one.getAuditStatus() == 3) || one == null)) { + detail.setStatus(-1); + } else if (systemUser.getSystemRoleId() == 0) { + // 查是否是当前层级处理 不是则都是正在办理 + if (detail.getNowLevel() != 3 && detail.getStatus() != 3 && detail.getStatus() != 8) { + detail.setStatus(0); + } + } else if (detail.getStatus() != 3 && detail.getStatus() != 8 && detail.getFirstStatus() == 0 && detail.getNowLevel() == 3) { + detail.setStatus(5); + } else if (detail.getStatus() == 3 || detail.getStatus() == 8) { + detail.setStatus(detail.getStatus()); + } else { detail.setStatus(0); } + } + } if (systemUser.getAccountLevel() == 4) { - if(detail.getNowLevel()==4 && detail.getAssignStatus()==0){ - detail.setStatus(-1); - } - if (systemUser.getSystemRoleId() == 0) { - // 查是否是当前层级处理 不是则都是正在办理 - if (detail.getNowLevel() != 4 && detail.getStatus() != 3 && detail.getStatus() != 8) { + if(detail.getStatus()!=5){ + if (detail.getStatus() != 3 && detail.getStatus() != 8 && detail.getNowLevel() == 4 && detail.getAssignStatus() == 0 && ((one != null && one.getAuditStatus() == 1)||(one != null && one.getAuditStatus() == 3) || one==null )) { + detail.setStatus(-1); + }else if (detail.getStatus() != 3 && detail.getStatus() != 8 && detail.getFirstStatus() == 0 && detail.getNowLevel()==4) { + detail.setStatus(5); + }else if(detail.getStatus()==3 || detail.getStatus()==8){ + detail.setStatus(detail.getStatus()); + }else { detail.setStatus(0); } } + + } - }else { - if(detail.getFirstStatus()==1){ + } else { + if (detail.getFirstStatus() == 1 && detail.getStatus() != 3 && detail.getStatus() != 8) { detail.setStatus(0); - }else { - detail.setStatus(-2); + } else if (detail.getFirstStatus() == 0 && detail.getCreateBy().equals(loginUserInfoVO.getUserId())) { + detail.setStatus(5); + } else if (detail.getFirstStatus() == 1 && detail.getStatus() == 3) { + detail.setStatus(3); + } else if (detail.getFirstStatus() == 1 && detail.getStatus() == 8) { + detail.setStatus(8); } } - if (detail.getStatus().equals(0)) { - List<ComplaintFlow> list = complaintFlowService.lambdaQuery().eq(ComplaintFlow::getComplaintId, id).orderByAsc(ComplaintFlow::getSort).list(); + if (true) { + List<ComplaintFlow> list = complaintFlowService.lambdaQuery().eq(ComplaintFlow::getComplaintId, id).orderByDesc(ComplaintFlow::getCreateTime).orderByAsc(ComplaintFlow::getType).list(); detail.setComplaintFlows(list); } //查询办理进度 @@ -650,9 +792,9 @@ buttonPermission(detail, systemUserByPhone, loginUserInfoVO); Long reporterId = detail.getReporterId(); Long superiorId = detail.getSuperiorId2(); - if (!String.valueOf(reporterId).equals(targetId) && !String.valueOf(superiorId).equals(targetId) && detail.getStatus() == 5) { - detail.setStatus(0); - } +// if (!String.valueOf(reporterId).equals(targetId) && !String.valueOf(superiorId).equals(targetId) && detail.getStatus() == 5 && systemUser==null) { +// detail.setStatus(0); +// } // if (auditButtonStatus == 1 && detail.getStatus() == 5 && !Objects.equals(detail.getAuditCreateBy(), loginUserInfoVO.getUserId())){ @@ -662,20 +804,45 @@ //已办结,显示评价按钮 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)){ - detail.setEvaluateButtonStatus(0); - } - }else{ - if(detail.getReportType() == 5){ - detail.setEvaluateButtonStatus(0); - } - } + //查询评价 + ComplaintComment comment = complaintCommentService.lambdaQuery().eq(ComplaintComment::getComplaintId, id).last("LIMIT 1").one(); + detail.setComplaintComment(comment); + if (detail.getStatus() == 3 && 0 == count) { + detail.setEvaluateButtonStatus(0); + }else { + detail.setEvaluateButtonStatus(1); } + + return detail; } + + + @Override + public ComplaintVO detailScreen(Long id) { + //获取当前身份,1=党员,2=管理员 + ComplaintVO detail = baseMapper.getDetail(id); + // 更新状态 此时status是表中的状态 未做变动 + if (detail.getFirstStatus() == 1 && detail.getStatus() != 3 && detail.getStatus() != 8) { + detail.setStatus(0); + } else if (detail.getFirstStatus() == 0) { + detail.setStatus(5); + } else if (detail.getFirstStatus() == 1 && detail.getStatus() == 3) { + detail.setStatus(3); + } else if (detail.getFirstStatus() == 1 && detail.getStatus() == 8) { + detail.setStatus(8); + } + + List<ComplaintFlow> list = complaintFlowService.lambdaQuery().eq(ComplaintFlow::getComplaintId, id).orderByDesc(ComplaintFlow::getCreateTime).orderByAsc(ComplaintFlow::getType).list(); + detail.setComplaintFlows(list); + //查询办理进度 + List<ComplaintProgress> list1 = complaintProgressService.lambdaQuery().eq(ComplaintProgress::getComplaintId, id) + .orderByAsc(ComplaintProgress::getCreateTime).list(); + detail.setComplaintProgresses(list1); + + return detail; + } + /** * 办理进度录入 @@ -754,6 +921,16 @@ double handlingDay = new BigDecimal(l).divide(new BigDecimal("24"), 2, RoundingMode.HALF_UP).doubleValue(); complaint.setHandlingDay(handlingDay); this.updateById(complaint); + + if (dto.getStatus() == 3) { + // 发送短信 + Long createBy = complaint.getCreateBy(); + + String phone = systemUserService.getCreateByIdPhone(createBy); + if (StringUtils.isNotEmpty(phone)) { + AliSmsUtil.sendSuccessMessage(phone); + } + } } /** @@ -784,11 +961,11 @@ Long reporterId = null; String departmentName = ""; String reporter = ""; - int nowLevel=0; + int nowLevel = 0; if (identityInformationVO.getIdentity() == 1) { PartyMember partyMember = partyMemberService.getPartyMemberByPhone(phone); superiorId = Long.valueOf(partyMember.getStreetId()); - lastSuperiorId= partyMember.getCommunityId(); + lastSuperiorId = partyMember.getCommunityId(); reporterId = partyMember.getId(); reportType = 4; @@ -811,7 +988,7 @@ if (accountLevel == ReportTypeEnum.COMMUNITY.getCode()) { superiorId = Long.parseLong(adminUser.getStreetId()); - lastSuperiorId = adminUser.getCommunityId(); + lastSuperiorId = adminUser.getCommunityId(); reporterId = adminUser.getCommunityId(); nowLevel = 3; @@ -862,8 +1039,10 @@ complaint.setSuperiorId(superiorId); complaint.setLastSuperiorId(lastSuperiorId); complaint.setNowLevel(nowLevel); - complaint.setLastLevel(nowLevel+1); + complaint.setLastLevel(nowLevel + 1); complaint.setAssignStatus(0); + complaint.setNowLevelTime(new Date()); + complaint.setNowLevelSms(0); updateById(complaint); // 标记最新 @@ -916,7 +1095,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 +1107,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 @@ -978,7 +1163,7 @@ complaintAuditRecord.setComplaintId(complaint.getId()); complaintAuditRecord.setReportType(systemUser.getAccountLevel()); Long superiorId = null; - int nowLevel=0; + int nowLevel = 0; switch (systemUser.getAccountLevel()) { case 1: @@ -986,22 +1171,24 @@ break; case 2: superiorId = Long.parseLong(systemUser.getStreetId()); - nowLevel=3; + nowLevel = 3; break; case 3: superiorId = systemUser.getCommunityId(); - nowLevel=4; + nowLevel = 4; break; case 4: superiorId = systemUser.getCommunityId(); - nowLevel=4; + nowLevel = 4; break; } complaint.setSuperiorId(superiorId); complaint.setLastSuperiorId(superiorId); complaint.setAssignStatus(0); complaint.setNowLevel(nowLevel); - complaint.setLastLevel( nowLevel); + complaint.setLastLevel(nowLevel); + complaint.setNowLevelTime(new Date()); + complaint.setNowLevelSms(0); this.updateById(complaint); complaintAuditRecord.setSuperiorId(superiorId); @@ -1051,11 +1238,9 @@ complaintAuditRecord.setAuditTime(new Date()); - if(systemUser.getSystemRoleId()!=1 || systemUser.getAccountLevel()!=complaintAuditRecord.getReporterLevel()){ - throw new ServiceException("无权审核"); + if (systemUser.getSystemRoleId() > 2 || systemUser.getAccountLevel() != complaintAuditRecord.getReporterLevel()) { + throw new ServiceException("无权审核"); } - - if (complaintReporAuditDTO.getAuditResult().equals(1)) { @@ -1069,14 +1254,38 @@ complaintAuditRecord2.setReportType(complaintAuditRecord.getReporterLevel()); complaintFlowService.createFlow(complaintAuditRecord2, 0, loginUserInfoVO.getUserId()); + // 通过修改状态 已经修改superiorId 和层级 不需要修改 superiorId Complaint complaint = this.getById(complaintReporAuditDTO.getId()); complaint.setAssignPersonId(complaintReporAuditDTO.getDeptId()); complaint.setAssignStatus(1); - complaint.setLastSuperiorId(complaint.getSuperiorId()); - complaint.setLastLevel(complaint.getNowLevel()); - this.updateById(complaint); + complaint.setFirstStatus(1); + complaint.setLastSuperiorId(complaint.getSuperiorId()); + complaint.setLastLevel(complaint.getNowLevel()); + complaint.setRemark(complaintReporAuditDTO.getRemark()); + complaint.setNowLevelTime(new Date()); + complaint.setNowLevelSms(0); + if (StringUtils.isEmpty(complaint.getProblemType())) { + complaint.setProblemType(complaintReporAuditDTO.getProblemType()); + } + // 分配流转 + ComplaintFlow complaintFlow = new ComplaintFlow(); + complaintFlow.setComplaintId(complaintReporAuditDTO.getId()); + complaintFlow.setLevel(complaintAuditRecord.getReporterLevel()); + Department byId = departmentService.getById(complaintReporAuditDTO.getDeptId()); + complaintFlow.setName(byId.getName()); + complaintFlow.setType(1); + complaintFlow.setCreateTime(new Date(System.currentTimeMillis() + 1000)); + complaintFlowService.save(complaintFlow); + + + this.updateById(complaint); + List<SystemUser> list = systemUserService.list(new LambdaQueryWrapper<SystemUser>().eq(SystemUser::getOneDepartmentId, complaintReporAuditDTO.getDeptId()).eq(SystemUser::getSystemRoleId, 1).eq(SystemUser::getStatus, 1)); + if (!list.isEmpty()) { + List<String> phoneList = list.stream().map(SystemUser::getPhone).collect(Collectors.toList()); + AliSmsUtil.sendAssignMessageAdmin(phoneList, complaint.getSerialNumber()); + } } else { complaintAuditRecord.setRejectReason(complaintReporAuditDTO.getRejectReason()); @@ -1090,6 +1299,8 @@ complaint.setAssignStatus(1); complaint.setSuperiorId(complaint.getLastSuperiorId()); complaint.setNowLevel(complaint.getLastLevel()); + complaint.setNowLevelTime(new Date()); + complaint.setNowLevelSms(0); this.updateById(complaint); } @@ -1106,7 +1317,7 @@ int reportType; String departmentName = ""; String reporter = ""; - int nowLevel=4; + int nowLevel = 4; if (identityInformation.getIdentity() == 1) { PartyMember partyMember = partyMemberService.getPartyMemberByPhone(loginUserInfoVO.getPhone()); superiorId = partyMember.getCommunityId(); @@ -1129,10 +1340,10 @@ superiorId = Long.parseLong(systemUser.getStreetId()); } else if (accountLevel == ReportTypeEnum.STREET.getCode()) { superiorId = Long.parseLong(systemUser.getDistrictsCode()); - nowLevel =4; + nowLevel = 4; } else if (accountLevel == ReportTypeEnum.DISTRICT.getCode()) { superiorId = Long.valueOf(systemUser.getDistrictsCode()); - nowLevel =3;// 攀枝花市 + nowLevel = 3;// 攀枝花市 } else { // 处理未预期的账号等级 throw new ServiceException("未知的账号等级"); @@ -1193,8 +1404,8 @@ Complaint byId = this.getById(dto.getComplaintId()); byId.setSuperiorId(superiorId); - byId.setNowLevel( nowLevel); - this.updateById(byId); + byId.setNowLevel(nowLevel); + this.updateById(byId); } @@ -1204,20 +1415,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 { @@ -1307,6 +1517,36 @@ 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() >2) { + throw new ServiceException("无权查看"); + } + Integer oneDepartmentId = adminUser.getOneDepartmentId(); + Department byId = departmentService.getById(oneDepartmentId); + LambdaQueryWrapper<Department> eq = new LambdaQueryWrapper<Department>().eq(Department::getTier, byId.getTier()); + if(byId.getTier()==2){ + eq.eq(Department::getDistrictsCode, byId.getDistrictsCode()); + } + if(byId.getTier()==3){ + eq.eq(Department::getStreetId, byId.getStreetId()); + } + if(byId.getTier()==4){ + eq.eq(Department::getCommunityId, byId.getCommunityId()); + } + List<Department> list1 = departmentService.list(eq); + for (Department department : list1) { + DispatchVO dispatchVO = new DispatchVO(); + dispatchVO.setId(department.getId().toString()); + dispatchVO.setName(department.getName()); + dispatchVOList.add(dispatchVO); + } + return dispatchVOList; + } + /** * 获取待办诉求 * @@ -1372,7 +1612,44 @@ */ @Override public Page<ComplaintVO> pageList(MgtComplaintQuery query, SystemUserVo loginUserInfo) { - return baseMapper.pageList(new Page<>(query.getPageNum(), query.getPageSize()), query, loginUserInfo); + Page<ComplaintVO> complaintVOPage = new Page<>(); + if (loginUserInfo.getAccountLevel() == 2) { + if (loginUserInfo.getSystemRoleId() == 1 || loginUserInfo.getSystemRoleId() == 2) { + complaintVOPage = baseMapper.pageList(new Page<>(query.getPageNum(), query.getPageSize()), query, loginUserInfo); + } else { + complaintVOPage = baseMapper.pageList1(new Page<>(query.getPageNum(), query.getPageSize()), query, loginUserInfo); + } + } + if (loginUserInfo.getAccountLevel() == 3) { + if (loginUserInfo.getSystemRoleId() == 1 || loginUserInfo.getSystemRoleId() == 2) { + // 获取这个街道所管的社区id + List<Long> communityIds = comActService.list(new LambdaQueryWrapper<ComAct>().eq(ComAct::getStreetId, loginUserInfo.getStreetId())).stream().map(ComAct::getCommunityId).collect(Collectors.toList()); + complaintVOPage = baseMapper.pageList2(new Page<>(query.getPageNum(), query.getPageSize()), query, loginUserInfo, communityIds); + } else { + complaintVOPage = baseMapper.pageList1(new Page<>(query.getPageNum(), query.getPageSize()), query, loginUserInfo); + } + } + if (loginUserInfo.getAccountLevel() == 4) { + if (loginUserInfo.getSystemRoleId() == 1 || loginUserInfo.getSystemRoleId() == 2) { + complaintVOPage = baseMapper.pageList3(new Page<>(query.getPageNum(), query.getPageSize()), query, loginUserInfo); + } else { + complaintVOPage = baseMapper.pageList1(new Page<>(query.getPageNum(), query.getPageSize()), query, loginUserInfo); + } + } + + for (ComplaintVO record : complaintVOPage.getRecords()) { + int count = complaintCommentService.count(new LambdaQueryWrapper<ComplaintComment>().eq(ComplaintComment::getComplaintId, record.getId())); + if (count > 0) { + record.setEvaluateButtonStatus(1); + } else { + if (record.getStatus() == 3 ) { + record.setEvaluateButtonStatus(0); + } else { + record.setEvaluateButtonStatus(1); + } + } + } + return complaintVOPage; } @Override @@ -1412,7 +1689,32 @@ */ @Override public void export(MgtComplaintQuery query, SystemUserVo loginUserInfo) throws IOException { - List<ComplaintVO> list = baseMapper.getList(query, loginUserInfo); + List<ComplaintVO> list = null; + + if (loginUserInfo.getAccountLevel() == 2) { + if (loginUserInfo.getSystemRoleId() == 1 || loginUserInfo.getSystemRoleId() == 2) { + list = baseMapper.pageListExport(query, loginUserInfo); + } else { + list = baseMapper.pageList1Export(query, loginUserInfo); + } + } + if (loginUserInfo.getAccountLevel() == 3) { + if (loginUserInfo.getSystemRoleId() == 1 || loginUserInfo.getSystemRoleId() == 2) { + // 获取这个街道所管的社区id + List<Long> communityIds = comActService.list(new LambdaQueryWrapper<ComAct>().eq(ComAct::getStreetId, loginUserInfo.getStreetId())).stream().map(ComAct::getCommunityId).collect(Collectors.toList()); + list = baseMapper.pageList2Export(query, loginUserInfo, communityIds); + } else { + list = baseMapper.pageList1Export(query, loginUserInfo); + } + } + if (loginUserInfo.getAccountLevel() == 4) { + if (loginUserInfo.getSystemRoleId() == 1 || loginUserInfo.getSystemRoleId() == 2) { + list = baseMapper.pageList3Export(query, loginUserInfo); + } else { + list = baseMapper.pageList1Export(query, loginUserInfo); + } + } + List<ComplaintExcel> complaintExcels = BeanUtil.copyToList(list, ComplaintExcel.class); response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"); response.setCharacterEncoding("utf-8"); @@ -1424,6 +1726,10 @@ .doWrite(complaintExcels); } + // ComplaintVO(reporter=何健豪, reporterId=1676144498628919300, superiorId2=510403, auditCreateBy=1892421828085837826, reporterLevel=2, reporterPhone=null, departmentName=西区-金江镇, reportTime=Tue Jun 03 15:06:01 CST 2025, comment=1111, nickname=null, phone=null, auditorName=null, auditorPhone=null, rejectReason=null, auditTime=null, complaintFlows=null, complaintProgresses=null, auditButtonStatus=null, withdrawButtonStatus=null, rate=null, complaintComment=null, listControlsButtonStatus=null, evaluateButtonStatus=0, voiceFileList=null, progressCount=null, assignmentCount=null, reportCount=null, remindStatus=0, remindTime=null, reportStr=自办, deptName=aa) +// ComplaintVO(reporter=null, reporterId=null, superiorId2=null, auditCreateBy=null, reporterLevel=null, reporterPhone=null, departmentName=null, reportTime=null, comment=null, nickname=null, phone=null, auditorName=null, auditorPhone=null, rejectReason=null, auditTime=null, complaintFlows=null, complaintProgresses=null, auditButtonStatus=null, withdrawButtonStatus=null, rate=null, complaintComment=null, listControlsButtonStatus=null, evaluateButtonStatus=0, voiceFileList=null, progressCount=null, assignmentCount=null, reportCount=null, remindStatus=0, remindTime=null, reportStr=自办, deptName=aa) +// ComplaintVO(reporter=刘, reporterId=1552661132500668416, superiorId2=510403, auditCreateBy=1892403820151992322, reporterLevel=2, reporterPhone=null, departmentName=西区-格里坪镇, reportTime=Fri Jun 27 10:04:18 CST 2025, comment=null, nickname=null, phone=null, auditorName=null, auditorPhone=null, rejectReason=null, auditTime=null, complaintFlows=null, complaintProgresses=null, auditButtonStatus=null, withdrawButtonStatus=null, rate=null, complaintComment=null, listControlsButtonStatus=null, evaluateButtonStatus=0, voiceFileList=null, progressCount=null, assignmentCount=null, reportCount=null, remindStatus=0, remindTime=null, reportStr=自办, deptName=null) +// ComplaintVO(reporter=null, reporterId=null, superiorId2=null, auditCreateBy=null, reporterLevel=null, reporterPhone=null, departmentName=null, reportTime=null, comment=null, nickname=null, phone=null, auditorName=null, auditorPhone=null, rejectReason=null, auditTime=null, complaintFlows=null, complaintProgresses=null, auditButtonStatus=null, withdrawButtonStatus=null, rate=null, complaintComment=null, listControlsButtonStatus=null, evaluateButtonStatus=0, voiceFileList=null, progressCount=null, assignmentCount=null, reportCount=null, remindStatus=0, remindTime=null, reportStr=自办, deptName=aa) @Override public String downloadFile(Long id, Integer type, SystemUserVo loginUserInfo) throws IOException { Complaint complaint = baseMapper.getDetailBg(id); @@ -1595,7 +1901,7 @@ } @Override - public AnalyticStatisticsOneVo analyticStatisticsOne(AnalyticStatisticsQuery query, List<Complaint> complaints, SimpleDateFormat simpleDateFormat) { + public AnalyticStatisticsOneVo analyticStatisticsOne(AnalyticStatisticsQuery query, List<Complaint> complaints, SimpleDateFormat simpleDateFormat, Integer level) { String nowYearMonth; String lastYearMonth; int value = LocalDate.now().getMonth().getValue(); @@ -1617,18 +1923,18 @@ if (CollUtil.isEmpty(ids)) { ids.add(0, -1L); } - complaints = this.baseMapper.getStatusForList(ids); + complaints = this.baseMapper.getStatusForList(ids, level); AnalyticStatisticsOneVo vo = new AnalyticStatisticsOneVo(); // 诉求单量总计 vo.setAllTotal(complaints.size()); // 诉求单量本月 - int thisMonthTotal = (int) complaints.stream().filter(e -> simpleDateFormat.format(e.getCreateTime()).contains(nowYearMonth)).count(); + int thisMonthTotal = (int) complaints.stream().filter(e -> simpleDateFormat.format(e.getTime()).contains(nowYearMonth)).count(); vo.setThisMonthTotal(thisMonthTotal); // 诉求单量同比上月 - int lastMonthTotal = (int) complaints.stream().filter(e -> simpleDateFormat.format(e.getCreateTime()).contains(lastYearMonth)).count(); + int lastMonthTotal = (int) complaints.stream().filter(e -> simpleDateFormat.format(e.getTime()).contains(lastYearMonth)).count(); vo.setLastMonthCompareTotal(thisMonthTotal - lastMonthTotal); // 正在办理 @@ -1652,11 +1958,11 @@ vo.setOvertimeTransactTotal(overtimeComplaints.size()); // 超时办理本月 - int thisMonthOvertimeTransactTotal = (int) overtimeComplaints.stream().filter(e -> simpleDateFormat.format(e.getCreateTime()).contains(nowYearMonth)).count(); + int thisMonthOvertimeTransactTotal = (int) overtimeComplaints.stream().filter(e -> simpleDateFormat.format(e.getTime()).contains(nowYearMonth)).count(); vo.setThisMonthOvertimeTransactTotal(thisMonthOvertimeTransactTotal); // 超时办理同比上月 - int lastMonthOvertimeTransactTotal = (int) overtimeComplaints.stream().filter(e -> simpleDateFormat.format(e.getCreateTime()).contains(lastYearMonth)).count(); + int lastMonthOvertimeTransactTotal = (int) overtimeComplaints.stream().filter(e -> simpleDateFormat.format(e.getTime()).contains(lastYearMonth)).count(); vo.setLastMonthOvertimeTransactCompareTotal(thisMonthOvertimeTransactTotal - lastMonthOvertimeTransactTotal); // 平均处理时长 @@ -1665,20 +1971,20 @@ averageDay = BigDecimal.valueOf(averageDay).setScale(2, RoundingMode.HALF_UP).doubleValue(); vo.setAverageTime(averageDay); - List<Complaint> thisMonthAverageTimeComplaints = complaints.stream().filter(e -> simpleDateFormat.format(e.getCreateTime()).contains(nowYearMonth)).collect(Collectors.toList()); + List<Complaint> thisMonthAverageTimeComplaints = complaints.stream().filter(e -> simpleDateFormat.format(e.getTime()).contains(nowYearMonth)).collect(Collectors.toList()); if (thisMonthAverageTimeComplaints.size() > 0) { double thisMonthAverageTime = thisMonthAverageTimeComplaints.stream().mapToDouble(v -> v.getHandlingDay() == null ? 0 : v.getHandlingDay()).average().getAsDouble(); thisMonthAverageTime = BigDecimal.valueOf(thisMonthAverageTime).setScale(2, RoundingMode.HALF_UP).doubleValue(); vo.setThisMonthAverageTime(thisMonthAverageTime); } - List<Complaint> lastMonthAverageTimeComplaints = complaints.stream().filter(e -> simpleDateFormat.format(e.getCreateTime()).contains(lastYearMonth)).collect(Collectors.toList()); + List<Complaint> lastMonthAverageTimeComplaints = complaints.stream().filter(e -> simpleDateFormat.format(e.getTime()).contains(lastYearMonth)).collect(Collectors.toList()); if (lastMonthAverageTimeComplaints.size() > 0) { double lastMonthAverageTime = lastMonthAverageTimeComplaints.stream().mapToDouble(v -> v.getHandlingDay() == null ? 0 : v.getHandlingDay()).average().getAsDouble(); BigDecimal lastMonthAverageTime1 = BigDecimal.valueOf(lastMonthAverageTime).setScale(2, RoundingMode.HALF_UP); - vo.setLastMonthCompareAverageTime( new BigDecimal(vo.getThisMonthAverageTime()).subtract(lastMonthAverageTime1).setScale(2,RoundingMode.HALF_UP).doubleValue()); - }else { - vo.setLastMonthCompareAverageTime( new BigDecimal(vo.getThisMonthAverageTime()).setScale(2,RoundingMode.HALF_UP).doubleValue()); + vo.setLastMonthCompareAverageTime(new BigDecimal(vo.getThisMonthAverageTime()).subtract(lastMonthAverageTime1).setScale(2, RoundingMode.HALF_UP).doubleValue()); + } else { + vo.setLastMonthCompareAverageTime(new BigDecimal(vo.getThisMonthAverageTime()).setScale(2, RoundingMode.HALF_UP).doubleValue()); } @@ -1691,7 +1997,7 @@ BigDecimal multiply = BigDecimal.valueOf(count).divide(new BigDecimal(size), 2, BigDecimal.ROUND_HALF_UP).multiply(new BigDecimal("100")); vo.setSatisfactionRate(multiply.doubleValue()); - List<Complaint> nowMonth = commentRateComplaints.stream().filter(e -> simpleDateFormat.format(e.getCreateTime()).contains(nowYearMonth)).collect(Collectors.toList()); + List<Complaint> nowMonth = commentRateComplaints.stream().filter(e -> simpleDateFormat.format(e.getTime()).contains(nowYearMonth)).collect(Collectors.toList()); // 当月满意 long count1 = nowMonth.stream().filter(e -> e.getCommentRate() > 1).count(); // 当月的评价数 @@ -1701,7 +2007,7 @@ vo.setThisMonthSatisfactionRate(multiply1.doubleValue()); } - List<Complaint> lastMonth = commentRateComplaints.stream().filter(e -> simpleDateFormat.format(e.getCreateTime()).contains(lastYearMonth)).collect(Collectors.toList()); + List<Complaint> lastMonth = commentRateComplaints.stream().filter(e -> simpleDateFormat.format(e.getTime()).contains(lastYearMonth)).collect(Collectors.toList()); // 当月满意 long count2 = lastMonth.stream().filter(e -> e.getCommentRate() > 1).count(); // 当月的评价数 @@ -1709,7 +2015,7 @@ if (lastMonthSize > 0) { BigDecimal multiply2 = BigDecimal.valueOf(count2).divide(new BigDecimal(lastMonthSize), 2, BigDecimal.ROUND_HALF_UP).multiply(new BigDecimal("100")); vo.setLastMonthCompareSatisfactionRate(vo.getThisMonthSatisfactionRate() - multiply2.doubleValue()); - }else { + } else { vo.setLastMonthCompareSatisfactionRate(vo.getThisMonthSatisfactionRate()); } } @@ -1718,9 +2024,11 @@ public static void main(String[] args) { + LocalDate localDate = LocalDate.now().plusDays(2); + String time = "2022-02-02 - 2023-02-02"; String[] split = time.split(" - "); - System.out.println(split[0]); + System.out.println(localDate.toString()); } @Override @@ -1731,7 +2039,7 @@ String[] split = time.split(" - "); Date parse = simpleDateFormat.parse(split[0] + " 00:00:00"); Date parse1 = simpleDateFormat.parse(split[1] + " 23:59:59"); - complaints = complaints.stream().filter(e -> e.getCreateTime().getTime() <= parse1.getTime() && e.getCreateTime().getTime() >= parse.getTime()).collect(Collectors.toList()); + complaints = complaints.stream().filter(e -> e.getTime().getTime() <= parse1.getTime() && e.getTime().getTime() >= parse.getTime()).collect(Collectors.toList()); int day = DateUtils.getDay(parse, parse1); if (day > 30) { @@ -1741,7 +2049,7 @@ for (int i = 0; i <= day; i++) { AnalyticStatisticsTwoVo analyticStatisticsTwoVo = new AnalyticStatisticsTwoVo(); if (i == 0) { - List<Complaint> collect = complaints.stream().filter(e -> simpleDateFormat.format(e.getCreateTime()).contains(split[0])).collect(Collectors.toList()); + List<Complaint> collect = complaints.stream().filter(e -> simpleDateFormat.format(e.getTime()).contains(split[0])).collect(Collectors.toList()); analyticStatisticsTwoVo.setTime(split[0]); analyticStatisticsTwoVo.setAllTotal(collect.size()); int count = (int) collect.stream().filter(e -> e.getStatus() == 3).count(); @@ -1749,7 +2057,7 @@ list.add(analyticStatisticsTwoVo); } else { String nextDay = DateUtils.getNextDay(parse, i); - List<Complaint> collect = complaints.stream().filter(e -> simpleDateFormat.format(e.getCreateTime()).contains(nextDay)).collect(Collectors.toList()); + List<Complaint> collect = complaints.stream().filter(e -> simpleDateFormat.format(e.getTime()).contains(nextDay)).collect(Collectors.toList()); analyticStatisticsTwoVo.setTime(nextDay); analyticStatisticsTwoVo.setAllTotal(collect.size()); int count = (int) collect.stream().filter(e -> e.getStatus() == 3).count(); @@ -1762,12 +2070,12 @@ time = DateUtils.getBeforeDay(6) + " 00:00:00"; Date parse = simpleDateFormat.parse(time); // 近7天数据 - complaints = complaints.stream().filter(e -> e.getCreateTime().getTime() <= new Date().getTime() && e.getCreateTime().getTime() >= parse.getTime()).collect(Collectors.toList()); + complaints = complaints.stream().filter(e -> e.getTime().getTime() <= new Date().getTime() && e.getTime().getTime() >= parse.getTime()).collect(Collectors.toList()); for (int i = 6; i >= 0; i--) { // 获取前7天的时间 String day = DateUtils.getBeforeDay(i); - List<Complaint> complaintList = complaints.stream().filter(e -> simpleDateFormat.format(e.getCreateTime()).contains(day)).collect(Collectors.toList()); + List<Complaint> complaintList = complaints.stream().filter(e -> simpleDateFormat.format(e.getTime()).contains(day)).collect(Collectors.toList()); AnalyticStatisticsTwoVo analyticStatisticsTwoVo = new AnalyticStatisticsTwoVo(); analyticStatisticsTwoVo.setTime(day); analyticStatisticsTwoVo.setAllTotal(complaintList.size()); @@ -1785,7 +2093,7 @@ @Override public List<AnalyticStatisticsThreeVo> analyticStatisticsThree(Integer rank, List<Complaint> complaints) { - Map<String, List<Complaint>> groupedByProblemType = complaints.stream() + Map<String, List<Complaint>> groupedByProblemType = complaints.stream().filter(e->e.getProblemType()!=null) .collect(Collectors.groupingBy(Complaint::getProblemType)); List<AnalyticStatisticsThreeVo> analyticStatisticsThreeVos = groupedByProblemType.entrySet().stream() .map(entry -> { @@ -1821,10 +2129,10 @@ long count3 = complaints.stream().filter(e -> e.getCommentRate() != null && e.getCommentRate() == 3).count(); vo.setGreatSatisfactionNum((int) count3); if (complaints.size() > 0) { - vo.setDissatisfactionRate(BigDecimal.valueOf(count).divide(BigDecimal.valueOf(complaints.size()),4,RoundingMode.HALF_UP).multiply(new BigDecimal("100")).setScale(2,RoundingMode.HALF_UP).doubleValue()); - vo.setGeneralSatisfactionRate(BigDecimal.valueOf(count1).divide(BigDecimal.valueOf(complaints.size()),4,RoundingMode.HALF_UP).multiply(new BigDecimal("100")).setScale(2,RoundingMode.HALF_UP).doubleValue()); - vo.setSatisfactionRate(BigDecimal.valueOf(count2).divide(BigDecimal.valueOf(complaints.size()),4,RoundingMode.HALF_UP).multiply(new BigDecimal("100")).setScale(2,RoundingMode.HALF_UP).doubleValue()); - vo.setGreatSatisfactionRate(BigDecimal.valueOf(count3).divide(BigDecimal.valueOf(complaints.size()),4,RoundingMode.HALF_UP).multiply(new BigDecimal("100")).setScale(2,RoundingMode.HALF_UP).doubleValue()); + vo.setDissatisfactionRate(BigDecimal.valueOf(count).divide(BigDecimal.valueOf(complaints.size()), 4, RoundingMode.HALF_UP).multiply(new BigDecimal("100")).setScale(2, RoundingMode.HALF_UP).doubleValue()); + vo.setGeneralSatisfactionRate(BigDecimal.valueOf(count1).divide(BigDecimal.valueOf(complaints.size()), 4, RoundingMode.HALF_UP).multiply(new BigDecimal("100")).setScale(2, RoundingMode.HALF_UP).doubleValue()); + vo.setSatisfactionRate(BigDecimal.valueOf(count2).divide(BigDecimal.valueOf(complaints.size()), 4, RoundingMode.HALF_UP).multiply(new BigDecimal("100")).setScale(2, RoundingMode.HALF_UP).doubleValue()); + vo.setGreatSatisfactionRate(BigDecimal.valueOf(count3).divide(BigDecimal.valueOf(complaints.size()), 4, RoundingMode.HALF_UP).multiply(new BigDecimal("100")).setScale(2, RoundingMode.HALF_UP).doubleValue()); } return vo; } @@ -1832,58 +2140,27 @@ @Override public List<Complaint> queryCompliantList(AppStaticsQuery query, LoginUserInfoVO loginUserInfo) { IdentityInformation identityInformation = identityInformationService.getIdentityInformation(loginUserInfo); - Integer identity = identityInformation.getIdentity(); - PartyMember partyMember = identityInformation.getPartyMember(); - SystemUserLevel systemUserLevel = identityInformation.getSystemUserLevel(); - Long targetId = null; - Integer accountLevel = 5; - //党员,查询该党员 - if (identity.equals(1)) { - targetId = partyMember.getId(); - } else if (identity.equals(2)) { - //上级 - if (Objects.nonNull(query.getTier()) && query.getTier().equals(-1)) { - accountLevel = systemUserLevel.getLevel(); - switch (systemUserLevel.getLevel()) { - case 1: - //市级 - targetId = 510400L; - break; - case 2: - //区县级 - targetId = Long.valueOf(systemUserLevel.getDistrictsCode()); - break; - case 3: - //街道 - targetId = Long.valueOf(systemUserLevel.getStreetId()); - break; - case 4: - //社区 - targetId = systemUserLevel.getCommunityId(); - break; - } - } else { - targetId = Long.valueOf(query.getAreaId()); - accountLevel = query.getTier(); - } + SystemUser systemUserLevel = identityInformation.getSystemUser(); + if (systemUserLevel.getSystemRoleId() == 1 || systemUserLevel.getSystemRoleId() == 2) { + return baseMapper.queryCompliantList(systemUserLevel.getAccountLevel(), systemUserLevel.getSystemRoleId(), query); } - return baseMapper.queryCompliantList(targetId, accountLevel, loginUserInfo, query); + return null; } @Override - public Page<SysUserVO> getDeptUserList(LoginUserInfoVO loginUserInfo,BasePage page) { + public Page<SysUserVO> getDeptUserList(LoginUserInfoVO loginUserInfo, BasePage page) { IdentityInformation currentIdentityInformation = identityInformationService.getCurrentIdentityInformation(loginUserInfo); if (currentIdentityInformation.getIdentity().equals(2)) { SystemUser systemUser = currentIdentityInformation.getSystemUser(); - if(systemUser.getSystemRoleId()!=1){ + if (systemUser.getSystemRoleId() != 1) { throw new ServiceException("你没有分配权限"); } Page<SysUserVO> sysUserVOPage = new Page<>(); ArrayList<SysUserVO> sysUserVOS = new ArrayList<>(); - Page<SystemUser> page1 = systemUserService.page(new Page<>(page.getPageNum(), page.getPageSize()), new LambdaQueryWrapper<SystemUser>().eq(SystemUser::getOneDepartmentId, systemUser.getOneDepartmentId()).ne(SystemUser::getId,systemUser.getId()).ne(SystemUser::getStatus, 3)); + Page<SystemUser> page1 = systemUserService.page(new Page<>(page.getPageNum(), page.getPageSize()), new LambdaQueryWrapper<SystemUser>().eq(SystemUser::getOneDepartmentId, systemUser.getOneDepartmentId()).ne(SystemUser::getId, systemUser.getId()).ne(SystemUser::getStatus, 3)); for (SystemUser record : page1.getRecords()) { SysUserVO sysUserVO = new SysUserVO(); sysUserVO.setId(record.getId()); @@ -1891,30 +2168,210 @@ sysUserVOS.add(sysUserVO); } sysUserVOPage.setRecords(sysUserVOS); - BeanUtils.copyProperties(page1,sysUserVOPage); + BeanUtils.copyProperties(page1, sysUserVOPage); return sysUserVOPage; - }else { + } else { throw new ServiceException("你没有分配权限"); } } @Override - public void assignComplain(LoginUserInfoVO loginUserInfo, Long complainId, Integer userId) { + public void assignComplain(LoginUserInfoVO loginUserInfo, Long complainId, Integer userId, String remark, String problemType) { IdentityInformation currentIdentityInformation = identityInformationService.getCurrentIdentityInformation(loginUserInfo); if (currentIdentityInformation.getIdentity().equals(2)) { SystemUser systemUser = currentIdentityInformation.getSystemUser(); Complaint complaint = baseMapper.selectById(complainId); + if (StringUtils.isEmpty(complaint.getProblemType())) { + complaint.setProblemType(problemType); + } + if (systemUser.getSystemRoleId() != 1 || !complaint.getNowLevel().equals(systemUser.getAccountLevel())) { + throw new ServiceException("你没有分配权限"); + } + // 已分配状态 complaint.setAssignPersonId(userId); complaint.setFirstStatus(1); complaint.setAssignStatus(1); - baseMapper.updateById(complaint); - }else { + complaint.setRemark(remark); + complaint.setNowLevelTime(new Date()); + complaint.setNowLevelSms(0); + baseMapper.updateById(complaint); + + Department department = departmentService.getById(userId); + ComplaintFlow complaintFlow = new ComplaintFlow(); + complaintFlow.setComplaintId(complainId); + complaintFlow.setLevel(complaint.getNowLevel()); + complaintFlow.setName(department.getName()); + complaintFlow.setCreateTime(new Date()); + complaintFlow.setType(1); + complaintFlowService.save(complaintFlow); + + + List<SystemUser> list = systemUserService.list(new LambdaQueryWrapper<SystemUser>().eq(SystemUser::getOneDepartmentId, userId).eq(SystemUser::getSystemRoleId, 1).eq(SystemUser::getStatus, 1)); + if (!list.isEmpty()) { + List<String> phoneList = list.stream().map(SystemUser::getPhone).collect(Collectors.toList()); + AliSmsUtil.sendAssignMessageAdmin(phoneList, complaint.getSerialNumber()); + } + + } else { throw new ServiceException("你没有分配权限"); } } + + @Override + public Page<ComplaintVO> pageScreenList(ScreenComplaintQuery query) { + + // 已分派了的 + Page<ComplaintVO> page = new Page<>(query.getPageNum(), query.getPageSize()); + + page = baseMapper.pageScreenList(page, query); + + page.getRecords().forEach(detail -> { + if (detail.getFirstStatus() == 1 && detail.getStatus() != 3 && detail.getStatus() != 8) { + detail.setStatus(0); + } else if (detail.getFirstStatus() == 0) { + detail.setStatus(5); + } else if (detail.getFirstStatus() == 1 && detail.getStatus() == 3) { + detail.setStatus(3); + } else if (detail.getFirstStatus() == 1 && detail.getStatus() == 8) { + detail.setStatus(8); + } + }); + return page; + } + + @Override + public Page<String> getHouseAddress(GetHouseAddressQuery query) { + Page<String> page = new Page<>(query.getPageNum(), query.getPageSize()); + return this.baseMapper.getHouseAddress(page, query.getAddress()); + } + + + @Override + public void saveComplaintAdmin(Complaint complaint, SystemUserVo systemUser) { + // 获取当前日期(年月日) + String datePrefix = new SimpleDateFormat("yyyyMMdd").format(new Date()); + + // 查询当前日期的最大流水号 + Complaint lastComplaint = getOne(new LambdaQueryWrapper<Complaint>() + .likeRight(Complaint::getSerialNumber, datePrefix) // 查询以当前日期开头的流水号 + .orderByDesc(Complaint::getSerialNumber) + .last("limit 1")); + + String serialNumber; + if (isNull(lastComplaint)) { + // 如果当天没有记录,从 0001 开始 + serialNumber = datePrefix + "0001"; + } else { + // 获取当前日期的最大流水号,并递增 + String lastSerialNumber = lastComplaint.getSerialNumber(); + int num = Integer.parseInt(lastSerialNumber.substring(lastSerialNumber.length() - 4)); // 提取后4位数字 + serialNumber = datePrefix + String.format("%04d", num + 1); // 递增并格式化为4位 + } + + // 设置流水号 + complaint.setSerialNumber(serialNumber); + Integer accountLevel = 4; + //获取当前身份 + //1=党员,2=管理员 + accountLevel = systemUser.getAccountLevel(); + switch (accountLevel) { + case 2: + //区县级 + complaint.setCityCode(510400); + complaint.setDistrictsCode(Integer.valueOf(systemUser.getDistrictsCode())); + complaint.setReportUserName(systemUser.getName()); + complaint.setReportUserPhone(systemUser.getPhone()); + + + complaint.setSuperiorId(Long.valueOf(systemUser.getDistrictsCode())); + break; + case 3: + //街道 + complaint.setCityCode(510400); + complaint.setDistrictsCode(Integer.valueOf(systemUser.getDistrictsCode())); + complaint.setStreetId(Long.valueOf(systemUser.getStreetId())); + complaint.setReportUserName(systemUser.getName()); + complaint.setReportUserPhone(systemUser.getPhone()); + + complaint.setSuperiorId(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()); + complaint.setReportUserName(systemUser.getName()); + complaint.setReportUserPhone(systemUser.getPhone()); + + complaint.setSuperiorId(systemUser.getCommunityId()); + break; + } + complaint.setCreateBy(Long.valueOf(systemUser.getId())); + complaint.setReportType(accountLevel); + complaint.setNowLevel(accountLevel); + complaint.setLastLevel(accountLevel); + complaint.setLastSuperiorId(complaint.getSuperiorId()); + + // 设置其他字段 + complaint.setStatus(ProcessStatusEnum.PROCESSING.getCode()); + complaint.setCreateTime(new Date(System.currentTimeMillis())); + complaint.setUpdateTime(new Date(System.currentTimeMillis())); + //查询系统配置诉求处理期限,设置截止日期 + WorkOrderItemConfig config = workOrderItemConfigService.lambdaQuery().orderByDesc(WorkOrderItemConfig::getId).last("LIMIT 1").one(); + if (Objects.isNull(config)) { + throw new ServiceException("工单事项未配置,请联系管理员"); + } + complaint.setNowLevelTime(new Date()); + complaint.setNowLevelSms(0); + // 保存诉求记录 + save(complaint); + } + + @Override + public void setProblemType(LoginUserInfoVO loginUserInfo, SetProblemTypeDto dto) { + IdentityInformation currentIdentityInformation = identityInformationService.getCurrentIdentityInformation(loginUserInfo); + if (currentIdentityInformation.getSystemUser().getSystemRoleId() != 1) { + throw new ServiceException("无权限"); + } + Complaint complaint = getById(dto.getComplaintId()); + complaint.setProblemType(dto.getProblemType()); + updateById(complaint); + } + + @Override + public Map<String, Integer> getComplaintTip(LoginUserInfoVO loginUserInfo) { + HashMap<String, Integer> map = new HashMap<>(); + IdentityInformation currentIdentityInformation = identityInformationService.getCurrentIdentityInformation(loginUserInfo); + SystemUser systemUser = currentIdentityInformation.getSystemUser(); + if (systemUser.getSystemRoleId() == 1) { + Integer accountLevel =systemUser.getAccountLevel(); + String code = null; + switch (accountLevel) { + case 2: + code ="510403"; + break; + case 3: + code =systemUser.getStreetId(); + break; + case 4: + code =systemUser.getCommunityId().toString(); + break; + default: + throw new ServiceException("无此权限"); + } + // 待分配 + map.put("waitAssign", this.baseMapper.getWaitAssign(accountLevel,code)); + // 待处理 + int count = this.count(new LambdaQueryWrapper<Complaint>().eq(Complaint::getAssignPersonId, systemUser.getOneDepartmentId()).notIn(Complaint::getStatus, 3, 8)); + map.put("waitProcess", count); + } + return map; + } + } -- Gitblit v1.7.1