From 53d014edd19f57125c355abe71ec5b478500e610 Mon Sep 17 00:00:00 2001 From: 无关风月 <443237572@qq.com> Date: 星期二, 05 八月 2025 09:57:40 +0800 Subject: [PATCH] 保洁巡检所有代码 --- ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/TAppealController.java | 382 +++++++++++++++++++++++++++++++++++++++++++++--------- 1 files changed, 317 insertions(+), 65 deletions(-) diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/TAppealController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/TAppealController.java index 66d457d..2cc7455 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/TAppealController.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/TAppealController.java @@ -3,6 +3,7 @@ import com.ruoyi.common.annotation.Log; import com.ruoyi.common.basic.PageInfo; +import com.ruoyi.common.core.domain.BaseModel; import com.ruoyi.common.core.domain.R; import com.ruoyi.common.core.domain.entity.SysUser; import com.ruoyi.common.enums.BusinessType; @@ -12,17 +13,25 @@ import com.ruoyi.system.model.*; import com.ruoyi.system.query.InsepectorListQuery; import com.ruoyi.system.service.*; +import com.ruoyi.system.utils.TemplateMessageSendUtil; import com.ruoyi.system.vo.system.AppealDetailVO; import com.ruoyi.system.vo.system.AppealListVO; +import com.ruoyi.web.controller.tool.EmailUtils; +import com.ruoyi.web.controller.tool.MsgUtils; +import com.tencentcloudapi.es.v20180416.models.TaskDetail; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; +import org.springframework.util.CollectionUtils; import org.springframework.util.StringUtils; import org.springframework.web.bind.annotation.*; import javax.annotation.Resource; import javax.validation.Valid; +import java.text.SimpleDateFormat; import java.time.LocalDateTime; import java.util.Arrays; +import java.util.Collections; +import java.util.Date; import java.util.List; import java.util.stream.Collectors; @@ -40,8 +49,6 @@ public class TAppealController { @Resource private TTaskCleanService taskCleanService; - - @Resource @@ -63,76 +70,102 @@ @Resource private TAppealService appealService; + @Resource + private TInspectorService inspectorService; + @Resource + private TInspectorDetailService inspectorDetailService; + @ApiOperation(value = "申诉记录分页列表") @PostMapping(value = "/pageList") public R<PageInfo<AppealListVO>> pageList(@RequestBody InsepectorListQuery query) { List<SysUser> sysUsers = sysUserService.selectAllList(); List<TLocation> locationList = locationService.list(); - if (StringUtils.hasLength(query.getDeptName())){ - List<String> projectIds = projectDeptService.lambdaQuery().like(TProjectDept::getProjectName, query.getDeptName()).list() + if (StringUtils.hasLength(query.getDeptName())) { + List<TProjectDept> list = projectDeptService.lambdaQuery().like(TProjectDept::getProjectName, query.getDeptName()).list(); + List<String> listIds = projectDeptService.lambdaQuery().like(TProjectDept::getProjectName, query.getDeptName()).list() .stream().map(TProjectDept::getId).collect(Collectors.toList()); + for (TProjectDept tProjectDept : list) { + if (tProjectDept.getParentId().equals("0")) { + List<String> collect = projectDeptService.lambdaQuery().eq(TProjectDept::getParentId, tProjectDept.getId()).list() + .stream().map(TProjectDept::getId).collect(Collectors.toList()); + listIds.addAll(collect); + } + } List<String> deptIds = deptService.lambdaQuery().like(TDept::getDeptName, query.getDeptName()).list() .stream().map(TDept::getId).collect(Collectors.toList()); - projectIds.addAll(deptIds); - if (projectIds.isEmpty()){ - return R.ok(new PageInfo<>()); + listIds.addAll(deptIds); + if (listIds.isEmpty()) { + listIds.add("0"); } - if (StringUtils.hasLength(query.getPhonenumber())){ + if (listIds.contains("0")) { + query.setPatrolInspectorIds(Collections.singletonList(0L)); + } else { + query.setPatrolInspectorIds(sysUsers.stream().filter(e -> listIds.contains(e.getDeptId())).map(SysUser::getUserId) + .collect(Collectors.toList())); + } + if (StringUtils.hasLength(query.getPhonenumber())) { List<Long> patrolInspectorIds = sysUsers.stream().filter(sysUser -> - sysUser.getPhonenumber().equals(query.getPhonenumber()) - && projectIds.contains(sysUser.getDeptId()) + sysUser.getPhonenumber().contains(query.getPhonenumber()) + && listIds.contains(sysUser.getDeptId()) ).map(SysUser::getUserId).collect(Collectors.toList()); - if (patrolInspectorIds.isEmpty()){ + if (patrolInspectorIds.isEmpty()) { return R.ok(new PageInfo<>()); } query.setPatrolInspectorIds(patrolInspectorIds); } } - if (StringUtils.hasLength(query.getPhonenumber())){ + if (StringUtils.hasLength(query.getPhonenumber())) { List<Long> patrolInspectorIds = sysUsers.stream().filter(sysUser -> - sysUser.getPhonenumber().equals(query.getPhonenumber()) + sysUser.getPhonenumber().contains(query.getPhonenumber()) ).map(SysUser::getUserId).collect(Collectors.toList()); - if (!query.getPatrolInspectorIds().isEmpty()){ + if (!CollectionUtils.isEmpty(query.getPatrolInspectorIds())) { // 取交集 patrolInspectorIds = patrolInspectorIds.stream().filter(query.getPatrolInspectorIds()::contains).collect(Collectors.toList()); } query.setPatrolInspectorIds(patrolInspectorIds); - if (patrolInspectorIds.isEmpty()){ + if (patrolInspectorIds.isEmpty()) { return R.ok(new PageInfo<>()); } } - if (query.getClearStatus()!=null){ + if (query.getClearStatus() != null) { List<String> collect = tTaskDetailService.lambdaQuery().eq(TTaskDetail::getClearStatus, query.getClearStatus()) - .list().stream().distinct().map(TTaskDetail::getTaskId).collect(Collectors.toList()); + .eq(TTaskDetail::getHandleType, 1) + .groupBy(TTaskDetail::getTaskId) + .orderByDesc(BaseModel::getCreateTime) + .list().stream().map(TTaskDetail::getTaskId).collect(Collectors.toList()); + query.setTaskIds(collect); - if (collect.isEmpty()){ + if (collect.isEmpty()) { return R.ok(new PageInfo<>()); } } - if (query.getLocationType()!=null){ + if (query.getLocationType() != null) { List<String> collect = locationList.stream().filter(e -> e.getLocationType().equals(query.getLocationType())).map(TLocation::getId) .collect(Collectors.toList()); - if (collect.isEmpty()){ + if (collect.isEmpty()) { return R.ok(new PageInfo<>()); } query.setLocationIds(collect); } - if (StringUtils.hasLength(query.getLocationName())){ + if (StringUtils.hasLength(query.getLocationName())) { List<String> collect = locationList.stream().filter(e -> e.getLocationName().contains(query.getLocationName())).map(TLocation::getId) .collect(Collectors.toList()); - if (collect.isEmpty()){ + if (collect.isEmpty()) { query.setLocationIds(collect); return R.ok(new PageInfo<>()); - }else{ - collect = collect.stream().filter(query.getLocationIds()::contains).collect(Collectors.toList()); - if (collect.isEmpty()){ - return R.ok(new PageInfo<>()); + } else { + if (query.getLocationIds() != null) { + collect = collect.stream().filter(query.getLocationIds()::contains).collect(Collectors.toList()); + if (collect.isEmpty()) { + return R.ok(new PageInfo<>()); + } } query.setLocationIds(collect); } } return R.ok(appealService.pageList(query)); } + @Log(title = "批量删除申诉记录", businessType = BusinessType.DELETE) @ApiOperation(value = "批量删除申诉记录") @DeleteMapping(value = "/deleteByIds") @@ -141,6 +174,7 @@ appealService.removeBatchByIds(Arrays.asList(split)); return R.ok(); } + @Log(title = "删除申诉记录", businessType = BusinessType.DELETE) @ApiOperation(value = "删除申诉记录") @DeleteMapping(value = "/deleteById") @@ -148,61 +182,279 @@ appealService.removeById(id); return R.ok(); } + @ApiOperation(value = "详情申诉记录") @GetMapping(value = "/detail") public R<AppealDetailVO> detail(@RequestParam String id) { AppealDetailVO appealDetailVO = new AppealDetailVO(); TAppeal appeal = appealService.getById(id); - BeanUtils.copyProperties(appeal,appealDetailVO); - TTask byId = taskCleanService.getById(appeal.getTaskId()); - TLocation byId1 = locationService.getById(byId.getLocationId()); - TLocationType byId2 = locationTypeService.getById(byId1.getLocationType()); - appealDetailVO.setLocationAddress(byId1.getLocationAddress()); - appealDetailVO.setLocationIcon(byId2.getLocationIcon()); - appealDetailVO.setLocationName(byId2.getLocationName()); - appealDetailVO.setTaskId(byId.getId()); - if (appeal.getAuditPerson()!=null){ - SysUser sysUser = sysUserService.selectUserById(Long.valueOf(appeal.getAuditPerson())); - if (sysUser!=null){ - appealDetailVO.setAuditPersonName(sysUser.getUserName()); + BeanUtils.copyProperties(appeal, appealDetailVO); + if (appeal.getInspectorId() != null) { + TInspector inspector = inspectorService.getById(appeal.getInspectorId()); + TLocation location = locationService.getById(inspector.getLocationId()); + TLocationType byId2 = locationTypeService.getById(location.getLocationType()); + appealDetailVO.setLocationAddress(location.getLocationAddress()); + appealDetailVO.setLocationIcon(byId2.getLocationIcon()); + appealDetailVO.setLocationName(location.getLocationName()); + appealDetailVO.setLocationTypeName(byId2.getLocationName()); + appealDetailVO.setTaskId(inspector.getId()); + if (appeal.getAuditPerson() != null) { + SysUser sysUser = sysUserService.selectUserById(Long.valueOf(appeal.getAuditPerson())); + if (sysUser != null) { + appealDetailVO.setAuditPersonName(sysUser.getUserName()); + } } + appealDetailVO.setTaskName(location.getLocationName()); + return R.ok(appealDetailVO); + + } else { + TTask byId = taskCleanService.getById(appeal.getTaskId()); + TLocation byId1 = locationService.getById(byId.getLocationId()); + TLocationType byId2 = locationTypeService.getById(byId1.getLocationType()); + appealDetailVO.setLocationAddress(byId1.getLocationAddress()); + appealDetailVO.setLocationIcon(byId2.getLocationIcon()); + appealDetailVO.setLocationName(byId1.getLocationName()); + appealDetailVO.setLocationTypeName(byId2.getLocationName()); + appealDetailVO.setTaskId(byId.getId()); + if (appeal.getAuditPerson() != null) { + SysUser sysUser = sysUserService.selectUserById(Long.valueOf(appeal.getAuditPerson())); + if (sysUser != null) { + appealDetailVO.setAuditPersonName(sysUser.getUserName()); + } + } + appealDetailVO.setTaskName(byId1.getLocationName()); + appealDetailVO.setTaskCode(byId.getTaskCode()); + return R.ok(appealDetailVO); + } - appealDetailVO.setTaskName(byId.getTaskName()); - appealDetailVO.setTaskCode(byId.getTaskCode()); - return R.ok(appealDetailVO); + } + @Resource private TNoticeService noticeService; + @Resource + private MsgUtils msgUtils; + @Resource + private TemplateMessageSendUtil templateMessageSendUtil; + @Resource + private TNoticeSetService noticeSetService; + @Resource + private TDictDataService dictDataService; + @Log(title = "审核申诉记录", businessType = BusinessType.UPDATE) @ApiOperation(value = "审核申诉记录") @PostMapping(value = "/audit") - public R<Boolean> audit(@RequestBody @Valid TAppealAuditDTO dto) { + public R<Boolean> audit(@RequestBody @Valid TAppealAuditDTO dto) throws Exception { + List<SysUser> sysUsers = sysUserService.selectAllList(); TAppeal appeal = appealService.getById(dto.getId()); - dto.setStatus(dto.getStatus()); - dto.setAuditPerson(tokenService.getLoginUser().getUserId()+""); - dto.setAuditTime(LocalDateTime.now()); - TTask task = taskCleanService.getById(appeal.getTaskId()); - TLocation location = locationService.getById(task.getLocationId()); - TNotice tNotice = new TNotice(); - tNotice.setUserId(dto.getAppealPerson()); - tNotice.setStatus(1); - tNotice.setDataId(dto.getId()); - dto.setAuditTime(LocalDateTime.now()); - if (dto.getStatus()==2){ - // 通过 - TTask byId = taskCleanService.getById(dto.getTaskId()); - byId.setStatus(6); - taskCleanService.updateById(byId); - tNotice.setNoticeType(5); - tNotice.setNoticeContent("【"+location.getLocationName()+"】任务申诉通过"); - }else{ - tNotice.setNoticeType(4); - tNotice.setNoticeContent("【"+location.getLocationName()+"】任务申诉驳回"); + if (appeal.getInspectorId() != null) { + SysUser sysUser1 = sysUsers.stream().filter(e -> e.getUserId().equals(Long.valueOf(appeal.getAppealPerson()))) + .findFirst().orElse(null); + dto.setStatus(dto.getStatus()); + dto.setAuditPerson(tokenService.getLoginUser().getUserId() + ""); + dto.setAuditTime(LocalDateTime.now()); + TInspector inspector = inspectorService.getById(appeal.getInspectorId()); + TLocation location1 = locationService.getById(inspector.getLocationId()); + TNotice tNotice1 = new TNotice(); + tNotice1.setUserId(appeal.getAppealPerson()); + tNotice1.setStatus(1); + tNotice1.setDataId(dto.getId()); + dto.setAuditTime(LocalDateTime.now()); + TInspectorDetail inspectorDetail = new TInspectorDetail(); + inspectorDetail.setInspectorId(appeal.getInspectorId()); + Long count1 = inspectorDetailService.lambdaQuery().eq(TInspectorDetail::getInspectorId, appeal.getInspectorId()) + .eq(TInspectorDetail::getHandleType, 1).count(); + TNoticeSet noticeSet1 = noticeSetService.lambdaQuery().eq(TNoticeSet::getType, 2).last("limit 1") + .one(); + // 邮箱 + TDictData email1 = dictDataService.lambdaQuery().eq(TDictData::getDataType, 4).one(); + // 授权码 + TDictData code1 = dictDataService.lambdaQuery().eq(TDictData::getDataType, 5).one(); + if (dto.getStatus() == 2) { + inspectorDetail.setClearStatus(1); + inspectorDetail.setAuditTime(LocalDateTime.now()); + inspectorDetail.setAuditPerson(tokenService.getLoginUser().getUserId() + ""); + inspectorDetail.setAuditStatus(1); + inspectorDetail.setAuditRemark(dto.getAuditRemark()); + inspectorDetail.setHandleType(5); + inspectorDetail.setAppealId(dto.getId()); + // 通过 + TInspector byId = inspectorService.getById(dto.getInspectorId()); + if (count1 > 1) { + byId.setStatus(5); + } else { + byId.setStatus(6); + } + inspectorService.updateById(byId); + tNotice1.setNoticeType(5); + tNotice1.setNoticeContent("【" + location1.getLocationName() + "】任务申诉通过"); + if (sysUser1 != null) { + switch (noticeSet1.getNoticeType()) { + case 1: + msgUtils.sendMsg3(sysUser1.getPhonenumber(), location1.getLocationName(), "通过"); + break; + case 2: + if (StringUtils.hasLength(email1.getDataContent()) && StringUtils.hasLength(code1.getDataContent()) + &&StringUtils.hasLength(sysUser1.getEmail()) + ) { + EmailUtils.sendEmail(sysUser1.getEmail(), email1.getDataContent(), code1.getDataContent(), "【" + location1.getLocationName() + "】任务申诉通过"); + } + break; + case 3: + if (StringUtils.hasLength(sysUser1.getOpenId())) { + Date date = new Date(); + + SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm"); + String format = simpleDateFormat.format(date); + templateMessageSendUtil.wxTemplateAppealResultRequest(sysUser1.getOpenId(), + location1.getLocationName(), "通过", format, dto.getAuditRemark()); + } + break; + } + } + } else { + inspectorDetail.setClearStatus(2); + inspectorDetail.setAuditTime(LocalDateTime.now()); + inspectorDetail.setAuditPerson(tokenService.getLoginUser().getUserId() + ""); + inspectorDetail.setAuditStatus(2); + inspectorDetail.setAuditRemark(dto.getAuditRemark()); + inspectorDetail.setHandleType(6); + inspectorDetail.setAppealId(dto.getId()); + tNotice1.setNoticeType(4); + tNotice1.setNoticeContent("【" + location1.getLocationName() + "】任务申诉驳回"); + if (sysUser1 != null) { + switch (noticeSet1.getNoticeType()) { + case 1: + msgUtils.sendMsg3(sysUser1.getPhonenumber(), location1.getLocationName(), "通过"); + break; + case 2: + if (StringUtils.hasLength(email1.getDataContent()) && StringUtils.hasLength(code1.getDataContent()) + + &&StringUtils.hasLength(sysUser1.getEmail())) { + EmailUtils.sendEmail(sysUser1.getEmail(), email1.getDataContent(), code1.getDataContent(), "【" + location1.getLocationName() + "】任务申诉驳回"); + } + break; + case 3: + if (StringUtils.hasLength(sysUser1.getOpenId())) { + Date date = new Date(); + + SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm"); + String format = simpleDateFormat.format(date); + templateMessageSendUtil.wxTemplateAppealResultRequest(sysUser1.getOpenId(), + location1.getLocationName(), "驳回", format, dto.getAuditRemark()); + } + break; + } + } + } + } else { + SysUser sysUser = sysUsers.stream().filter(e -> e.getUserId().equals(Long.valueOf(appeal.getAppealPerson()))) + .findFirst().orElse(null); + dto.setStatus(dto.getStatus()); + dto.setAuditPerson(tokenService.getLoginUser().getUserId() + ""); + dto.setAuditTime(LocalDateTime.now()); + TTask task = taskCleanService.getById(appeal.getTaskId()); + TLocation location = locationService.getById(task.getLocationId()); + TNotice tNotice = new TNotice(); + tNotice.setUserId(appeal.getAppealPerson()); + tNotice.setStatus(1); + tNotice.setDataId(dto.getId()); + dto.setAuditTime(LocalDateTime.now()); + TTaskDetail taskDetail = new TTaskDetail(); + taskDetail.setTaskId(appeal.getTaskId()); + Long count = tTaskDetailService.lambdaQuery().eq(TTaskDetail::getTaskId, appeal.getTaskId()) + .eq(TTaskDetail::getHandleType, 1).count(); + TNoticeSet noticeSet = noticeSetService.lambdaQuery().eq(TNoticeSet::getType, 2).last("limit 1") + .one(); + // 邮箱 + TDictData email = dictDataService.lambdaQuery().eq(TDictData::getDataType, 4).one(); + // 授权码 + TDictData code = dictDataService.lambdaQuery().eq(TDictData::getDataType, 5).one(); + if (dto.getStatus() == 2) { + taskDetail.setClearStatus(1); + taskDetail.setAuditTime(LocalDateTime.now()); + taskDetail.setAuditPerson(tokenService.getLoginUser().getUserId() + ""); + taskDetail.setAuditStatus(1); + taskDetail.setAuditRemark(dto.getAuditRemark()); + taskDetail.setHandleType(5); + taskDetail.setAppealId(dto.getId()); + // 通过 + TTask byId = taskCleanService.getById(dto.getTaskId()); + if (count > 1) { + byId.setStatus(5); + } else { + byId.setStatus(6); + + } + + taskCleanService.updateById(byId); + tNotice.setNoticeType(5); + tNotice.setNoticeContent("【" + location.getLocationName() + "】任务申诉通过"); + if (sysUser != null) { + switch (noticeSet.getNoticeType()) { + case 1: + msgUtils.sendMsg3(sysUser.getPhonenumber(), location.getLocationName(), "通过"); + break; + case 2: + if (StringUtils.hasLength(email.getDataContent()) && StringUtils.hasLength(code.getDataContent()) + + &&StringUtils.hasLength(sysUser.getEmail())) { + EmailUtils.sendEmail(sysUser.getEmail(), email.getDataContent(), code.getDataContent(), "【" + location.getLocationName() + "】任务申诉通过"); + } + break; + case 3: + if (StringUtils.hasLength(sysUser.getOpenId())) { + Date date = new Date(); + + SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm"); + String format = simpleDateFormat.format(date); + templateMessageSendUtil.wxTemplateAppealResultRequest(sysUser.getOpenId(), + location.getLocationName(), "通过", format, dto.getAuditRemark()); + } + break; + } + } + } else { + taskDetail.setClearStatus(2); + taskDetail.setAuditTime(LocalDateTime.now()); + taskDetail.setAuditPerson(tokenService.getLoginUser().getUserId() + ""); + taskDetail.setAuditStatus(2); + taskDetail.setAuditRemark(dto.getAuditRemark()); + taskDetail.setHandleType(6); + taskDetail.setAppealId(dto.getId()); + tNotice.setNoticeType(4); + tNotice.setNoticeContent("【" + location.getLocationName() + "】任务申诉驳回"); + if (sysUser != null) { + switch (noticeSet.getNoticeType()) { + case 1: + msgUtils.sendMsg3(sysUser.getPhonenumber(), location.getLocationName(), "通过"); + break; + case 2: + if (StringUtils.hasLength(email.getDataContent()) && StringUtils.hasLength(code.getDataContent()) + &&StringUtils.hasLength(sysUser.getEmail())) { + EmailUtils.sendEmail(sysUser.getEmail(), email.getDataContent(), code.getDataContent(), "【" + location.getLocationName() + "】任务申诉驳回"); + } + break; + case 3: + if (StringUtils.hasLength(sysUser.getOpenId())) { + Date date = new Date(); + + SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm"); + String format = simpleDateFormat.format(date); + templateMessageSendUtil.wxTemplateAppealResultRequest(sysUser.getOpenId(), + location.getLocationName(), "驳回", format, dto.getAuditRemark()); + } + break; + } + } + } + noticeService.save(tNotice); + dto.setAuditPerson(tokenService.getLoginUser().getUserId() + ""); + appealService.updateById(dto); + tTaskDetailService.save(taskDetail); } - noticeService.save(tNotice); - dto.setAuditPerson(tokenService.getLoginUser().getUserId()+""); - appealService.updateById(dto); return R.ok(); + } } -- Gitblit v1.7.1