Browse Source

2403 新需求:1、王处反应未收到过提示去处理待办的短信;2、此处设计为自动提醒,机制:累积5家单位超5天未处理自动发送提醒,提醒后清零重新计时

wengchengjian 1 year ago
parent
commit
762a023944

+ 29 - 3
ruoyi-system/src/main/java/com/ruoyi/ahrs/timingtask/TextMessageTask.java

@@ -8,7 +8,9 @@ import com.ruoyi.process.declaration.domain.Declaration;
 import com.ruoyi.process.declaration.domain.DeclarationVo;
 import com.ruoyi.process.declaration.service.IDeclarationService;
 import com.ruoyi.process.declaration.service.impl.BackfillAllDataAsync;
+import com.ruoyi.system.domain.SysDept;
 import com.ruoyi.system.domain.SysUser;
+import com.ruoyi.system.service.ISysDeptService;
 import com.ruoyi.system.service.ISysUserService;
 import org.apache.shiro.util.CollectionUtils;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -37,6 +39,9 @@ public class TextMessageTask {
     @Autowired
     private ISysUserService sysUserService;
 
+    @Autowired
+    private ISysDeptService sysDeptService;
+
     @Transactional
     public void textMessage() throws Exception {
         SysUser sysUser = sysUserService.selectUserByLoginName("wangjun");
@@ -44,8 +49,8 @@ public class TextMessageTask {
         declaration.setDeptId(sysUser.getDeptId());
         // 获取王军所有的待办
         List<DeclarationVo> list = declarationService.findTodoTasks("wangjun",declaration);
-        // 过滤出超过5天的申报
-        List<DeclarationVo> collect = list.stream().filter(p -> DateUtils.getDatePoorDay(new Date(), p.getUpdateTime()) >= 5).collect(Collectors.toList());
+        // 过滤出超过7天的申报
+        List<DeclarationVo> collect = list.stream().filter(p -> DateUtils.getDatePoorDay(new Date(), p.getUpdateTime()) >= 7).collect(Collectors.toList());
 
         // 合并的和单个的分开计算
         long count = collect.stream().filter(p -> StringUtils.isEmpty(p.getParentId())).count();
@@ -59,8 +64,29 @@ public class TextMessageTask {
         }
 
         if (count >= 5) {
+            // 获取第一条申报的单位名
+            String deptName = "";
+            for (DeclarationVo declarationVo : list) {
+                // 空就用本单位,非空就用父单位
+                SysDept sysDept = sysDeptService.selectDeptById(declarationVo.getDeptId());
+                if (StringUtils.isEmpty(declarationVo.getParentId())) {
+                    deptName = sysDept.getDeptName();
+                } else {
+                    deptName = sysDept.getParentName();
+                }
+                break;
+            }
+
+            // 计算申报数,合并的算一个
+            // 合并的和单个的分开计算
+            long num = list.stream().filter(p -> StringUtils.isEmpty(p.getParentId())).count();
+            Map<String, List<DeclarationVo>> listMap = list.stream().filter(p -> StringUtils.isNotEmpty(p.getParentId())).collect(Collectors.groupingBy(Declaration::getParentId));
+            if(!CollectionUtils.isEmpty(listMap)){
+                num += listMap.keySet().size();
+            }
+
             NoteUtil noteUtil = new NoteUtil();
-            noteUtil.setShortMessage(sysUser.getPhonenumber(),"您有5条以上的申报待处理,请及时处理。");
+            noteUtil.setShortMessage(sysUser.getPhonenumber(), "尊敬的终审领导,截至" + DateUtils.datePath2() + ",您在【安徽省事业单位人事管理信息系统】有" + deptName + "等" + num + "个单位待处理的审批,请及时处理。");
         }
     }
 }