yusm 1 тиждень тому
батько
коміт
2f6404942d

+ 6 - 0
fhKeeper/formulahousekeeper/management-crm/src/main/java/com/management/platform/controller/SysFormController.java

@@ -67,6 +67,12 @@ public class SysFormController {
         Integer companyId = userMapper.selectById(request.getHeader("token")).getCompanyId();
         Company company = companyMapper.selectById(companyId);
         List<SysForm> sysFormList = sysFormService.list(new LambdaQueryWrapper<SysForm>().eq(SysForm::getCompanyId, companyId).eq(SysForm::getCode, code));
+        for (SysForm sysForm : sysFormList) {
+            String config = sysForm.getConfig();
+            // 定位并替换
+            String fixedConfig = config.replace("\"pattern\":\"/^\\d+$/\"", "\"pattern\":\"/^\\\\d+$/\"");
+            sysForm.setConfig(fixedConfig);
+        }
         if (!sysFormList.isEmpty()&&company.getIsExistBusiness()==0){
             for (SysForm sysForm : sysFormList) {
                 String config = sysForm.getConfig();

+ 1 - 0
fhKeeper/formulahousekeeper/management-crm/src/main/java/com/management/platform/entity/dto/TaskDto.java

@@ -38,6 +38,7 @@ public class TaskDto extends Task {
     private List<TaskLog> taskLogs;
 
     private String contactsPhone;
+    private String color;
 
 
     private List<String> taskExecutors;

+ 23 - 117
fhKeeper/formulahousekeeper/management-crm/src/main/java/com/management/platform/service/impl/TaskServiceImpl.java

@@ -2513,8 +2513,6 @@ public class TaskServiceImpl extends ServiceImpl<TaskMapper, Task> implements Ta
 
 
         DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm");
-        DateTimeFormatter formatterDate = DateTimeFormatter.ofPattern("yyyy-MM-dd");
-        DateTimeFormatter formatterTime = DateTimeFormatter.ofPattern("HH:mm");
         LocalDateTime parseStartDate = LocalDateTime.parse(startDate + " 00:00", formatter);
         LocalDateTime parseEndDate = LocalDateTime.parse(endDate + " 00:00", formatter).plusDays(1L);
 
@@ -2531,7 +2529,12 @@ public class TaskServiceImpl extends ServiceImpl<TaskMapper, Task> implements Ta
 
         }
         List<TaskDto> taskDtoList = taskMapper.getTaskListByStartAndEnd(parseStartDate, parseEndDate, departmentId, executor, companyId);
-
+        // 为原始任务添加颜色
+        for (int i = 0; i < taskDtoList.size(); i++) {
+            TaskDto task = taskDtoList.get(i);
+            // 使用模运算循环使用预设颜色
+            task.setColor(COLOR_PALETTE[i % COLOR_PALETTE.length]);
+        }
 
         List<TaskRemind> remindList = taskRemindService.list(new QueryWrapper<TaskRemind>()
                 .between("remind_date", parseStartDate, parseEndDate)
@@ -2562,127 +2565,30 @@ public class TaskServiceImpl extends ServiceImpl<TaskMapper, Task> implements Ta
                     taskDtos.add(taskDto);
                 }
             }
-            taskDtoList.addAll(taskDtos);
-        }
-
-
-        /*if (type==1||type==2) {
-            // 使用LinkedHashMap保持日期顺序
-            Map<LocalDate, List<TaskDto>> dailyTasks = new LinkedHashMap<>();
-
-            // 生成从startDate到endDate的所有日期,并初始化空列表
-            LocalDate parseStart = LocalDate.parse(startDate, formatterDate);
-            LocalDate parseEnd = LocalDate.parse(endDate, formatterDate);
-            LocalDate currentDate = parseStart;
-            while (!currentDate.isAfter(parseEnd)) {
-                dailyTasks.put(currentDate, new ArrayList<>());
-                currentDate = currentDate.plusDays(1);
-            }
-
-            // 遍历任务,填充到对应的日期
-            for (TaskDto task : taskDtoList) {
-                // 根据实际字段获取任务日期,例如getExecuteDate()
-                LocalDateTime taskStartDate = task.getStartDate();
-                LocalDateTime taskEndDate = task.getEndDate();
-                if (taskStartDate != null && taskEndDate != null) {
-                    LocalDate task_start = LocalDate.from(taskStartDate);
-                    LocalDate task_end = LocalDate.from(taskEndDate);
-                    for (Map.Entry<LocalDate, List<TaskDto>> entry : dailyTasks.entrySet()) {
-                        LocalDate date = entry.getKey(); // 获取日期
-                        List<TaskDto> tasks = entry.getValue(); // 获取任务列表
-                        if (date.isAfter(task_start) && date.isBefore(task_end) || date.isEqual(task_start)) {
-                            tasks.add(task);
-                        }
-                    }
-                } else if (taskStartDate == null && taskEndDate != null) {
-                    LocalDate task_end = LocalDate.from(taskEndDate);
-                    for (Map.Entry<LocalDate, List<TaskDto>> entry : dailyTasks.entrySet()) {
-                        LocalDate date = entry.getKey(); // 获取日期
-                        List<TaskDto> tasks = entry.getValue(); // 获取任务列表
-                        if (date.isEqual(task_end)) {
-                            tasks.add(task);
-                        }
-                    }
-                } else if (taskStartDate != null) {
-                    LocalDate task_start = LocalDate.from(taskStartDate);
-                    for (Map.Entry<LocalDate, List<TaskDto>> entry : dailyTasks.entrySet()) {
-                        LocalDate date = entry.getKey(); // 获取日期
-                        List<TaskDto> tasks = entry.getValue(); // 获取任务列表
-                        if (date.isEqual(task_start)) {
-                            tasks.add(task);
-                        }
-                    }
-                }
-
+            // 为提醒任务也添加颜色
+            for (TaskDto taskDto : taskDtos) {
+                // 基于任务ID生成确定性的颜色,确保同一任务颜色一致
+                int colorIndex = Math.abs(taskDto.getTaskName().hashCode()) % COLOR_PALETTE.length;
+                taskDto.setColor(COLOR_PALETTE[colorIndex]);
             }
-            //自定义DTO类
-            List<DailyTaskVO> result = dailyTasks.entrySet().stream()
-                    .map(entry -> new DailyTaskVO(entry.getKey(), entry.getValue()))
-                    .collect(Collectors.toList());
-            msg.setData(result);
+            taskDtoList.addAll(taskDtos);
         }
-        else {
-            // 使用LinkedHashMap保持日期顺序
-            Map<LocalTime, List<TaskDto>> dailyTasks = new LinkedHashMap<>();
-
-            // 生成从startDate到endDate的所有日期,并初始化空列表
-            LocalTime startTime = LocalTime.of(6, 0);
-            LocalTime endTime = LocalTime.of(23, 0);
-
-            LocalTime currentTime = startTime;
-            while (!currentTime.isAfter(endTime)) {
-                dailyTasks.put(currentTime, new ArrayList<>());
-                currentTime = currentTime.plusMinutes(30);
-            }
-            // 遍历任务,填充到对应的日期
-            for (TaskDto task : taskDtoList) {
-                // 根据实际字段获取任务日期,例如getExecuteDate()
-                LocalDateTime taskStartDate = task.getStartDate();
-                LocalDateTime taskEndDate = task.getEndDate();
-                if (taskStartDate != null && taskEndDate != null) {
-                    LocalTime task_start = LocalTime.from(taskStartDate);
-                    LocalTime task_end = LocalTime.from(taskEndDate);
-                    for (Map.Entry<LocalTime, List<TaskDto>> entry : dailyTasks.entrySet()) {
-                        LocalTime date = entry.getKey(); // 获取日期
-                        List<TaskDto> tasks = entry.getValue(); // 获取任务列表
-                        if (date.isAfter(task_start) && date.isBefore(task_end) || date.equals(task_start)) {
-                            tasks.add(task);
-                        }
-                    }
-                }
-                else if (taskStartDate == null && taskEndDate != null) {
-                    LocalTime task_end = LocalTime.from(taskEndDate);
-                    for (Map.Entry<LocalTime, List<TaskDto>> entry : dailyTasks.entrySet()) {
-                        LocalTime date = entry.getKey(); // 获取日期
-                        List<TaskDto> tasks = entry.getValue(); // 获取任务列表
-                        if (date.equals(task_end)) {
-                            tasks.add(task);
-                        }
-                    }
-                }
-                else if (taskStartDate != null) {
-                    LocalTime task_start = LocalTime.from(taskStartDate);
-                    for (Map.Entry<LocalTime, List<TaskDto>> entry : dailyTasks.entrySet()) {
-                        LocalTime date = entry.getKey(); // 获取日期
-                        List<TaskDto> tasks = entry.getValue(); // 获取任务列表
-                        if (date.equals(task_start)) {
-                            tasks.add(task);
-                        }
-                    }
-                }
-            }
-            //自定义DTO类
-            List<TimeTaskVO> result = dailyTasks.entrySet().stream()
-                    .map(entry -> new TimeTaskVO(entry.getKey(), entry.getValue()))
-                    .collect(Collectors.toList());
-            msg.setData(result);
-        }*/
-
         msg.setData(taskDtoList);
         return msg;
 
     }
 
+    // 定义一组美观的颜色
+    private static final String[] COLOR_PALETTE = {
+            "#FF6B6B", // 红色
+            "#4ECDC4", // 青色
+            "#45B7D1", // 蓝色
+            "#FFA07A", // 橙色
+            "#98D8C8", // 绿色
+            "#A28AFF", // 紫色
+            "#FFD166"  // 黄色
+    };
+
     @Override
     public HttpRespMsg exportDataAI(TaskDto taskDto, HttpServletRequest request) throws Exception {
         User user = userMapper.selectById(request.getHeader("token"));