Przeglądaj źródła

修改任务开始,结束时间,对应的代码

yusm 2 miesięcy temu
rodzic
commit
0d6bc7fbf8

+ 6 - 7
fhKeeper/formulahousekeeper/management-crm/src/main/java/com/management/platform/entity/ContractPayment.java

@@ -1,20 +1,19 @@
 package com.management.platform.entity;
 
-import java.math.BigDecimal;
-
 import com.baomidou.mybatisplus.annotation.IdType;
-import com.baomidou.mybatisplus.extension.activerecord.Model;
-import java.time.LocalDate;
-import com.baomidou.mybatisplus.annotation.TableId;
 import com.baomidou.mybatisplus.annotation.TableField;
-import java.io.Serializable;
-
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.extension.activerecord.Model;
 import com.fasterxml.jackson.annotation.JsonFormat;
 import lombok.Data;
 import lombok.EqualsAndHashCode;
 import lombok.experimental.Accessors;
 import org.springframework.format.annotation.DateTimeFormat;
 
+import java.io.Serializable;
+import java.math.BigDecimal;
+import java.time.LocalDate;
+
 /**
  * <p>
  * 

+ 6 - 6
fhKeeper/formulahousekeeper/management-crm/src/main/java/com/management/platform/entity/Task.java

@@ -181,18 +181,18 @@ public class Task extends Model<Task> {
     /**
      * 截止时间
      */
-    @JsonFormat(pattern = "yyyy-MM-dd")
-    @DateTimeFormat(pattern = "yyyy-MM-dd")
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm")
+    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm")
     @TableField("end_date")
-    private LocalDate endDate;
+    private LocalDateTime endDate;
 
     /**
      * 开始日期
      */
-    @JsonFormat(pattern = "yyyy-MM-dd")
-    @DateTimeFormat(pattern = "yyyy-MM-dd")
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm")
+    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm")
     @TableField("start_date")
-    private LocalDate startDate;
+    private LocalDateTime startDate;
 
     /**
      * 完成日期

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

@@ -35,6 +35,7 @@ import java.lang.reflect.Field;
 import java.lang.reflect.Method;
 import java.time.LocalDate;
 import java.time.LocalDateTime;
+import java.time.LocalTime;
 import java.time.format.DateTimeFormatter;
 import java.util.*;
 import java.util.regex.Matcher;
@@ -143,13 +144,13 @@ public class TaskServiceImpl extends ServiceImpl<TaskMapper, Task> implements Ta
         BeanUtils.copyProperties(taskDto,task);
         task.setCreateDate(LocalDateTime.now());//任务的创建时间
         //根据任务的开始时间与当下时间判断任务的状态
-        if (taskDto.getStartDate()!=null&&taskDto.getStartDate().isAfter(LocalDate.now())){
+        if (taskDto.getStartDate()!=null&&taskDto.getStartDate().isAfter(LocalDateTime.now())){
 //            task.setStatus(0);
             //20250116 未开始状态废弃,默认进行中
             task.setStatus(1);
-        }else if (taskDto.getEndDate()!=null&&taskDto.getEndDate().isBefore(LocalDate.now())){
+        }else if (taskDto.getEndDate()!=null&&taskDto.getEndDate().isBefore(LocalDateTime.now())){
             task.setStatus(3);
-        } else if (taskDto.getStartDate()!=null&&(taskDto.getStartDate().isBefore(LocalDate.now())||taskDto.getStartDate().isEqual(LocalDate.now()))&&taskDto.getEndDate()!=null&&(taskDto.getEndDate().isAfter(LocalDate.now())||taskDto.getEndDate().isEqual(LocalDate.now()))) {
+        } else if (taskDto.getStartDate()!=null&&(taskDto.getStartDate().isBefore(LocalDateTime.now())||taskDto.getStartDate().isEqual(LocalDateTime.now()))&&taskDto.getEndDate()!=null&&(taskDto.getEndDate().isAfter(LocalDateTime.now())||taskDto.getEndDate().isEqual(LocalDateTime.now()))) {
             task.setStatus(1);
         }
         task.setCreaterName(user.getName());
@@ -300,13 +301,13 @@ public class TaskServiceImpl extends ServiceImpl<TaskMapper, Task> implements Ta
             msg.setError("请保证时间段的顺序性");
             return msg;
         }
-        if (taskDto.getStartDate()!=null&&taskDto.getStartDate().isAfter(LocalDate.now())){
+        if (taskDto.getStartDate()!=null&&taskDto.getStartDate().isAfter(LocalDateTime.now())){
 //            task.setStatus(0);
             //20250116 未开始状态废弃,默认进行中
             task.setStatus(1);
-        }else if (taskDto.getEndDate()!=null&&taskDto.getEndDate().isBefore(LocalDate.now())){
+        }else if (taskDto.getEndDate()!=null&&taskDto.getEndDate().isBefore(LocalDateTime.now())){
             task.setStatus(3);
-        } else if (taskDto.getStartDate()!=null&&taskDto.getStartDate().isBefore(LocalDate.now())&&taskDto.getEndDate()!=null&&taskDto.getEndDate().isAfter(LocalDate.now()))
+        } else if (taskDto.getStartDate()!=null&&taskDto.getStartDate().isBefore(LocalDateTime.now())&&taskDto.getEndDate()!=null&&taskDto.getEndDate().isAfter(LocalDateTime.now()))
         {
             task.setStatus(1);
         }
@@ -609,15 +610,30 @@ public class TaskServiceImpl extends ServiceImpl<TaskMapper, Task> implements Ta
                         if(cell != null && cell.getCellTypeEnum() != CellType.BLANK){
                             if(!StringUtils.isEmpty(cell.getStringCellValue())){
                                 try {
-                                     int count = Integer.parseInt(cell.getStringCellValue());
-                                    // Excel中的日期序列号的基准日期是1900年1月1日
+//                                     double count = Double.parseDouble(cell.getStringCellValue());
+//                                    // Excel中的日期序列号的基准日期是1900年1月1日
+//                                    LocalDateTime baseDate = LocalDateTime.of(1900, 1, 1,0,0,0);
+//                                    LocalDateTime dateTime = baseDate.plusDays(count-2);// Excel的基准日期是1900年1月0日,所以需要减去2天
+//                                    task.setStartDate(dateTime);
+                                    // 将字符串转换为 double
+                                    double excelDate = Double.parseDouble(cell.getStringCellValue());
+
+                                    // 计算日期部分
                                     LocalDate baseDate = LocalDate.of(1900, 1, 1);
-                                    LocalDate date = baseDate.plusDays(count - 2); // Excel的基准日期是1900年1月0日,所以需要减去2天
-                                    task.setStartDate(date);
+                                    LocalDate date = baseDate.plusDays((int) excelDate - 2); // 减去 2 天,因为 Excel 基准日期是 1900年1月1日
+
+                                    // 计算时间部分
+                                    double timeFraction = excelDate - Math.floor(excelDate); // 获取小数部分
+                                    LocalTime time = LocalTime.ofSecondOfDay((long) (timeFraction * 86400)); // 86400 是一天的秒数
+
+                                    // 合并日期和时间
+                                    LocalDateTime dateTime = LocalDateTime.of(date, time);
+                                    task.setStartDate(dateTime);
+
 
                                 } catch (Exception e) {
-                                    System.out.println("日期时间格式不正确,应该是yyyy/MM/dd" );
-                                    msg.setError("日期时间格式不正确,应该是yyyy/MM/dd");
+                                    System.out.println("日期时间格式不正确,应该是yyyy/MM/dd HH:mm:ss" );
+                                    msg.setError("日期时间格式不正确,应该是yyyy/MM/dd HH:mm:ss");
                                     return msg;
                                 }
                             }
@@ -627,15 +643,29 @@ public class TaskServiceImpl extends ServiceImpl<TaskMapper, Task> implements Ta
                         if(cell != null && cell.getCellTypeEnum() != CellType.BLANK){
                             if(!StringUtils.isEmpty(cell.getStringCellValue())){
                                 try {
-                                    int count = Integer.parseInt(cell.getStringCellValue());
+                                    /*int count = Integer.parseInt(cell.getStringCellValue());
                                     // Excel中的日期序列号的基准日期是1900年1月1日
+                                    LocalDateTime baseDate = LocalDateTime.of(1900, 1, 1,0,0,0);
+                                    LocalDateTime dateTime = baseDate.plusDays(count-2);// Excel的基准日期是1900年1月0日,所以需要减去2天
+                                    task.setEndDate(dateTime);*/
+                                    // 将字符串转换为 double
+                                    double excelDate = Double.parseDouble(cell.getStringCellValue());
+
+                                    // 计算日期部分
                                     LocalDate baseDate = LocalDate.of(1900, 1, 1);
-                                    LocalDate date = baseDate.plusDays(count - 2); // Excel的基准日期是1900年1月0日,所以需要减去2天
-                                    task.setEndDate(date);
+                                    LocalDate date = baseDate.plusDays((int) excelDate - 2); // 减去 2 天,因为 Excel 基准日期是 1900年1月1日
+
+                                    // 计算时间部分
+                                    double timeFraction = excelDate - Math.floor(excelDate); // 获取小数部分
+                                    LocalTime time = LocalTime.ofSecondOfDay((long) (timeFraction * 86400)); // 86400 是一天的秒数
+
+                                    // 合并日期和时间
+                                    LocalDateTime dateTime = LocalDateTime.of(date, time);
+                                    task.setEndDate(dateTime);
 
                                 } catch (Exception e) {
-                                    System.out.println("日期时间格式不正确,应该是yyyy/MM/dd" );
-                                    msg.setError("日期时间格式不正确,应该是yyyy/MM/dd");
+                                    System.out.println("日期时间格式不正确,应该是yyyy/MM/dd HH:mm:ss" );
+                                    msg.setError("日期时间格式不正确,应该是yyyy/MM/dd HH:mm:ss");
                                     return msg;
                                 }
                             }
@@ -833,13 +863,13 @@ public class TaskServiceImpl extends ServiceImpl<TaskMapper, Task> implements Ta
                         msg.setError("任务:"+task.getTaskName()+"中客户/"+str+"/销售订单不应一同存在");
                         return msg;
                     }
-                    if (task.getStartDate()!=null&&task.getStartDate().isAfter(LocalDate.now())){
+                    if (task.getStartDate()!=null&&task.getStartDate().isAfter(LocalDateTime.now())){
 //                        task.setStatus(0);
                         //20250116 未开始状态废弃,默认进行中
                         task.setStatus(1);
-                    }else if (task.getEndDate()!=null&&task.getEndDate().isBefore(LocalDate.now())){
+                    }else if (task.getEndDate()!=null&&task.getEndDate().isBefore(LocalDateTime.now())){
                         task.setStatus(3);
-                    } else if (task.getStartDate()!=null&&task.getStartDate().isBefore(LocalDate.now())&&task.getEndDate()!=null&&task.getEndDate().isAfter(LocalDate.now()))
+                    } else if (task.getStartDate()!=null&&task.getStartDate().isBefore(LocalDateTime.now())&&task.getEndDate()!=null&&task.getEndDate().isAfter(LocalDateTime.now()))
                     {
                         task.setStatus(1);
                     }
@@ -1036,18 +1066,18 @@ public class TaskServiceImpl extends ServiceImpl<TaskMapper, Task> implements Ta
                 }
                 else if(model.equals("startDate")){
                     if (tasKVo.getStartDate()!=null){
-                        LocalDate startDate = tasKVo.getStartDate();
+                        LocalDateTime startDate = tasKVo.getStartDate();
                         // 定义日期时间格式
-                        DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
+                        DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm");
                         // 格式化为字符串
                         value= startDate.format(formatter);
                     }
                 }
                 else if(model.equals("endDate")){
                     if (tasKVo.getEndDate()!=null){
-                        LocalDate endDate = tasKVo.getEndDate();
+                        LocalDateTime endDate = tasKVo.getEndDate();
                         // 定义日期时间格式
-                        DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
+                        DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm");
                         // 格式化为字符串
                         value= endDate.format(formatter);
                     }
@@ -1101,7 +1131,7 @@ public class TaskServiceImpl extends ServiceImpl<TaskMapper, Task> implements Ta
         if(0 == taskDto.getStatus()){
             //重启相关判断
             //重启的任务必须要修改开始时间为当前日期之后
-            LocalDate nowDate = LocalDate.now();
+            LocalDateTime nowDate = LocalDateTime.now();
             if(taskDto.getStartDate().isBefore(nowDate)){
                 msg.setError("开始日期不能早于当前日期");
                 return msg;
@@ -1217,18 +1247,18 @@ public class TaskServiceImpl extends ServiceImpl<TaskMapper, Task> implements Ta
                 }
                 else if(model.equals("startDate")){
                     if (tasKVo.getStartDate()!=null){
-                        LocalDate startDate = tasKVo.getStartDate();
+                        LocalDateTime startDate = tasKVo.getStartDate();
                         // 定义日期时间格式
-                        DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
+                        DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm");
                         // 格式化为字符串
                         value= startDate.format(formatter);
                     }
                 }
                 else if(model.equals("endDate")){
                     if (tasKVo.getEndDate()!=null){
-                        LocalDate endDate = tasKVo.getEndDate();
+                        LocalDateTime endDate = tasKVo.getEndDate();
                         // 定义日期时间格式
-                        DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
+                        DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm");
                         // 格式化为字符串
                         value= endDate.format(formatter);
                     }

+ 12 - 40
fhKeeper/formulahousekeeper/management-crm/src/main/java/com/management/platform/task/TimingTask.java

@@ -1,60 +1,32 @@
 package com.management.platform.task;
 
-import com.alibaba.fastjson.JSON;
-import com.alibaba.fastjson.JSONArray;
-import com.alibaba.fastjson.JSONObject;
-import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
-import com.baomidou.mybatisplus.core.injector.methods.SelectById;
-import com.management.platform.controller.WeiXinCorpController;
-import com.management.platform.entity.*;
 import com.management.platform.entity.Task;
-import com.management.platform.entity.vo.TokenVo;
+import com.management.platform.entity.TaskExecutor;
+import com.management.platform.entity.User;
+import com.management.platform.entity.WxCorpInfo;
 import com.management.platform.mapper.*;
-import com.management.platform.service.*;
-import com.management.platform.service.impl.WxCorpInfoServiceImpl;
-import com.management.platform.util.*;
-import com.management.platform.webservice.po.*;
-import jdk.nashorn.internal.ir.ContinueNode;
+import com.management.platform.service.OperationRecordService;
+import com.management.platform.service.WxCorpInfoService;
+import com.management.platform.util.RedisUtil;
 import lombok.extern.slf4j.Slf4j;
-import me.chanjar.weixin.mp.api.WxMpInMemoryConfigStorage;
-import me.chanjar.weixin.mp.api.WxMpService;
-import me.chanjar.weixin.mp.api.impl.WxMpServiceImpl;
-import me.chanjar.weixin.mp.bean.template.WxMpTemplateData;
-import me.chanjar.weixin.mp.bean.template.WxMpTemplateMessage;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Value;
-import org.springframework.http.*;
-import org.springframework.http.client.ClientHttpResponse;
 import org.springframework.scheduling.annotation.EnableScheduling;
 import org.springframework.scheduling.annotation.Scheduled;
 import org.springframework.stereotype.Component;
-import org.springframework.transaction.annotation.Transactional;
-import org.springframework.util.StringUtils;
-import org.springframework.web.client.DefaultResponseErrorHandler;
 import org.springframework.web.client.RestTemplate;
 
 import javax.annotation.Resource;
 import java.io.File;
-import java.io.IOException;
-import java.math.BigDecimal;
-import java.security.SecureRandom;
-import java.sql.Time;
-import java.sql.Timestamp;
-import java.text.DecimalFormat;
-import java.time.*;
-import java.time.Period;
-import java.time.format.DateTimeFormatter;
-import java.time.temporal.TemporalAccessor;
-import java.time.temporal.TemporalAdjusters;
-import java.time.temporal.WeekFields;
-import java.util.*;
-import java.util.concurrent.*;
+import java.time.LocalDateTime;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.concurrent.Executor;
+import java.util.concurrent.Executors;
 import java.util.stream.Collectors;
 import java.util.stream.IntStream;
 
-import static org.apache.logging.log4j.message.ParameterizedMessage.format;
-
 /**
  * Author: 吴涛涛
  * Date : 2019 - 12 - 31 16:04
@@ -149,7 +121,7 @@ public class TimingTask {
 //        List<WxCorpInfo> wxCorpInfos = wxCorpInfoMapper.selectList(new QueryWrapper<WxCorpInfo>().eq("company_id", 5770));
         List<WxCorpInfo> wxCorpInfos = wxCorpInfoMapper.selectList(null);
         for (WxCorpInfo wxCorpInfo : wxCorpInfos) {
-            LocalDate now = LocalDate.now();
+            LocalDateTime now = LocalDateTime.now();
             List<Task> taskList = taskMapper.selectList(new QueryWrapper<Task>().eq("company_id", wxCorpInfo.getCompanyId()).eq("status",0).and(wrapper -> wrapper.eq("end_date", now).or().eq("end_date", now.plusDays(1))));
             List<User> userList = userMapper.selectList(new QueryWrapper<User>().eq("company_id", wxCorpInfo.getCompanyId()));
             List<Integer> taskIds = taskList.stream().map(Task::getId).distinct().collect(Collectors.toList());