From 25b19e60e004290531f61fdf608d1adb5e531903 Mon Sep 17 00:00:00 2001 From: 无关风月 <443237572@qq.com> Date: 星期六, 12 七月 2025 14:40:12 +0800 Subject: [PATCH] 保洁巡检本周代码 --- ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/TAppealController.java | 167 ++++++++++++++++++++++++++++++++++++++++++++----------- 1 files changed, 133 insertions(+), 34 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 f76ad96..c232c77 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 @@ -10,16 +10,17 @@ import com.ruoyi.common.utils.bean.BeanUtils; import com.ruoyi.framework.web.service.TokenService; import com.ruoyi.system.dto.TAppealAuditDTO; -import com.ruoyi.system.dto.TTaskAuditDTO; import com.ruoyi.system.model.*; import com.ruoyi.system.query.InsepectorListQuery; import com.ruoyi.system.service.*; import com.ruoyi.system.vo.system.AppealDetailVO; import com.ruoyi.system.vo.system.AppealListVO; -import com.ruoyi.system.vo.system.InspectorListVO; -import com.ruoyi.system.vo.system.TaskDetailVO; +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.*; @@ -43,34 +44,28 @@ @RequestMapping("/t-appeal") public class TAppealController { @Resource - private TTaskService taskService; + private TTaskCleanService taskCleanService; - @Resource - private TTaskDetailService taskDetailService; + @Resource private TLocationTypeService locationTypeService; @Resource private TLocationService locationService; - @Resource - private TProjectDeptService projectDeptService; - @Resource - private TCleanerService cleanerService; - @Resource - private TTaskService tTaskService; + @Resource private TTaskDetailService tTaskDetailService; + @Resource + private TProjectDeptService projectDeptService; @Resource private TDeptService deptService; @Resource private ISysUserService sysUserService; - @Resource - private TDictDataService dictDataService; + @Resource private TokenService tokenService; - @Resource - private TInspectorService inspectorService; + @Resource private TAppealService appealService; @ApiOperation(value = "申诉记录分页列表") @@ -79,18 +74,28 @@ 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() + 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"); } + 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()) + && listIds.contains(sysUser.getDeptId()) ).map(SysUser::getUserId).collect(Collectors.toList()); if (patrolInspectorIds.isEmpty()){ return R.ok(new PageInfo<>()); @@ -102,7 +107,7 @@ List<Long> patrolInspectorIds = sysUsers.stream().filter(sysUser -> sysUser.getPhonenumber().equals(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()); } @@ -113,7 +118,11 @@ } 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()){ return R.ok(new PageInfo<>()); @@ -134,9 +143,11 @@ 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<>()); + 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); } @@ -164,34 +175,122 @@ AppealDetailVO appealDetailVO = new AppealDetailVO(); TAppeal appeal = appealService.getById(id); BeanUtils.copyProperties(appeal,appealDetailVO); - TTask byId = taskService.getById(appeal.getTaskId()); + 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()); - SysUser sysUser = sysUserService.selectUserById(Long.valueOf(appeal.getAuditPerson())); - if (sysUser!=null){ - appealDetailVO.setAuditPersonName(sysUser.getUserName()); + if (appeal.getAuditPerson()!=null){ + SysUser sysUser = sysUserService.selectUserById(Long.valueOf(appeal.getAuditPerson())); + if (sysUser!=null){ + appealDetailVO.setAuditPersonName(sysUser.getUserName()); + } } appealDetailVO.setTaskName(byId.getTaskName()); appealDetailVO.setTaskCode(byId.getTaskCode()); return R.ok(appealDetailVO); } + @Resource + private TNoticeService noticeService; + @Resource + private MsgUtils msgUtils; + @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()); + SysUser sysUser = sysUsers.stream().filter(e -> e.getUserId().equals(Long.valueOf(dto.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 = taskService.getById(dto.getTaskId()); - byId.setStatus(6); - taskService.updateById(byId); + 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())){ + EmailUtils.sendEmail(sysUser.getEmail(),email.getDataContent(),code.getDataContent(),"【"+location.getLocationName()+"】任务申诉通过"); + } + break; + case 3: + 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())){ + EmailUtils.sendEmail(sysUser.getEmail(),email.getDataContent(),code.getDataContent(),"【"+location.getLocationName()+"】任务申诉驳回"); + } + break; + case 3: + break; + } + } } + noticeService.save(tNotice); dto.setAuditPerson(tokenService.getLoginUser().getUserId()+""); appealService.updateById(dto); + tTaskDetailService.save(taskDetail); return R.ok(); } } -- Gitblit v1.7.1