From 5e2d78f61bf7d1513d5d5c8cd55442133a6e898e Mon Sep 17 00:00:00 2001
From: 无关风月 <443237572@qq.com>
Date: 星期一, 14 七月 2025 18:23:36 +0800
Subject: [PATCH] 保洁巡检本周代码

---
 ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/TAppealController.java |   84 +++++++++++++++++++++++++++++++++++++++---
 1 files changed, 78 insertions(+), 6 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 a8d58d5..1619bb2 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
@@ -13,8 +13,11 @@
 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;
@@ -24,8 +27,11 @@
 
 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;
 
@@ -88,11 +94,15 @@
             if (listIds.isEmpty()){
                 listIds.add("0");
             }
-            query.setPatrolInspectorIds(sysUsers.stream().filter(e->listIds.contains(e.getDeptId())).map(SysUser::getUserId)
-                    .collect(Collectors.toList()));
+            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())
+                        sysUser.getPhonenumber().contains(query.getPhonenumber())
                                 && listIds.contains(sysUser.getDeptId())
                 ).map(SysUser::getUserId).collect(Collectors.toList());
                 if (patrolInspectorIds.isEmpty()){
@@ -103,7 +113,7 @@
         }
         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 (!CollectionUtils.isEmpty(query.getPatrolInspectorIds())){
                 // 取交集
@@ -178,7 +188,8 @@
         TLocationType byId2 = locationTypeService.getById(byId1.getLocationType());
         appealDetailVO.setLocationAddress(byId1.getLocationAddress());
         appealDetailVO.setLocationIcon(byId2.getLocationIcon());
-        appealDetailVO.setLocationName(byId2.getLocationName());
+        appealDetailVO.setLocationName(byId1.getLocationName());
+        appealDetailVO.setLocationTypeName(byId2.getLocationName());
         appealDetailVO.setTaskId(byId.getId());
         if (appeal.getAuditPerson()!=null){
             SysUser sysUser = sysUserService.selectUserById(Long.valueOf(appeal.getAuditPerson()));
@@ -192,11 +203,22 @@
     }
     @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());
+        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());
@@ -211,6 +233,12 @@
         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());
@@ -231,6 +259,28 @@
             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:
+                        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());
@@ -241,6 +291,28 @@
             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:
+                        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()+"");

--
Gitblit v1.7.1