From ac499486cf06e9e06834ed5c182f26267d871b9b Mon Sep 17 00:00:00 2001
From: xuhy <3313886187@qq.com>
Date: 星期二, 08 七月 2025 15:08:21 +0800
Subject: [PATCH] bug修改

---
 ruoyi-admin/src/main/java/com/ruoyi/web/controller/task/TaskUtil.java |   18 ++++++++++++++----
 1 files changed, 14 insertions(+), 4 deletions(-)

diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/task/TaskUtil.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/task/TaskUtil.java
index d679c65..d1ff21f 100644
--- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/task/TaskUtil.java
+++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/task/TaskUtil.java
@@ -90,7 +90,7 @@
         // 通过模板id查询员工巡检员
         List<SysUser> sysUsers = sysUserService.selectUserByTempLateId(template.getId());
         // 创建任务
-        list.forEach(detail -> {
+        for (TTemplateDetail detail : list) {
             // 计算周期
             int cycle = detail.getCycle();
             switch (detail.getCycleType()){
@@ -116,6 +116,13 @@
             int num3 = detail.getNum3();
             // 获取点位类型的占比
             String num4 = detail.getNum4();
+
+            // 未绑定员工
+            if(CollectionUtils.isEmpty(sysUsers)){
+                continue;
+            }
+
+
 
             SysUser sysUser = sysUsers.get(0);
             List<TProjectDept> projectDeptLists = new ArrayList<>();
@@ -189,7 +196,7 @@
             }
             int dayCleanerCount = cleanerSums / cycle;
 
-            if((cycle - detail.getCurrentValue()) == 1 && cleanerSums % cycle != 0){
+            if((cycle == detail.getCurrentValue()) && cleanerSums % cycle != 0){
                 dayCleanerCount++;
             }
 
@@ -271,6 +278,10 @@
                 detail.setCurrentValue(0);
                 // 将重复点位置空
                 redisCache.deleteObject(detail.getId() + REPEAT_LOCATION);
+                // 将项目部权重置空
+                redisCache.deleteObject(detail.getId() + PROJECT_DEPT_WEIGHT);
+                // 将保洁员权重置空
+                redisCache.deleteObject(detail.getId() + CLEANER_WEIGHT);
             }
 
             // 创建任务
@@ -308,8 +319,7 @@
             template.setTaskCount(tasks.size());
             templateService.updateById(template);
             templateDetailService.updateById(detail);
-        });
-
+        }
     }
 
     /**

--
Gitblit v1.7.1