添加字段
This commit is contained in:
parent
7969b8debd
commit
c59ca56d97
|
|
@ -36,6 +36,7 @@ public class TaskPlanConvert {
|
|||
model.setStartDate(entity.getStartDate());
|
||||
model.setEndDate(entity.getEndDate());
|
||||
model.setExecuteTime(entity.getExecuteTime());
|
||||
model.setDuration(entity.getDuration());
|
||||
model.setRouteId(entity.getRouteId());
|
||||
model.setUavId(entity.getUavId());
|
||||
model.setStatus(StatusEnum.getByCode(entity.getStatus()));
|
||||
|
|
@ -70,6 +71,7 @@ public class TaskPlanConvert {
|
|||
entity.setStartDate(model.getStartDate());
|
||||
entity.setEndDate(model.getEndDate());
|
||||
entity.setExecuteTime(model.getExecuteTime());
|
||||
entity.setDuration(model.getDuration());
|
||||
entity.setRouteId(model.getRouteId());
|
||||
entity.setUavId(model.getUavId());
|
||||
entity.setStatus(model.getStatus() != null ? model.getStatus().getCode() : null);
|
||||
|
|
|
|||
|
|
@ -54,9 +54,12 @@ public class TaskPlan {
|
|||
*
|
||||
* 对于定时任务
|
||||
* executeTime 就是执行时间
|
||||
*/
|
||||
/** 执行时间(仅在定义任务时有效) */
|
||||
private Date executeTime;
|
||||
|
||||
/** 执行时长 秒 */
|
||||
private Integer duration;
|
||||
|
||||
/** 航线ID */
|
||||
private Long routeId;
|
||||
|
||||
|
|
@ -157,6 +160,14 @@ public class TaskPlan {
|
|||
this.executeTime = executeTime;
|
||||
}
|
||||
|
||||
public Integer getDuration() {
|
||||
return duration;
|
||||
}
|
||||
|
||||
public void setDuration(Integer duration) {
|
||||
this.duration = duration;
|
||||
}
|
||||
|
||||
public Long getRouteId() {
|
||||
return routeId;
|
||||
}
|
||||
|
|
@ -241,6 +252,7 @@ public class TaskPlan {
|
|||
", startDate=" + startDate +
|
||||
", endDate=" + endDate +
|
||||
", executeTime=" + executeTime +
|
||||
", duration=" + duration +
|
||||
", routeId=" + routeId +
|
||||
", uavId=" + uavId +
|
||||
", status=" + status +
|
||||
|
|
|
|||
|
|
@ -35,6 +35,9 @@ public class TaskPlanEntity extends BaseEntity {
|
|||
/** 执行时间 */
|
||||
private Date executeTime;
|
||||
|
||||
/** 执行时长 秒 */
|
||||
private Integer duration;
|
||||
|
||||
/** 开始日期 */
|
||||
private Date startDate;
|
||||
|
||||
|
|
@ -109,6 +112,14 @@ public class TaskPlanEntity extends BaseEntity {
|
|||
this.executeTime = executeTime;
|
||||
}
|
||||
|
||||
public Integer getDuration() {
|
||||
return duration;
|
||||
}
|
||||
|
||||
public void setDuration(Integer duration) {
|
||||
this.duration = duration;
|
||||
}
|
||||
|
||||
public Date getStartDate() {
|
||||
return startDate;
|
||||
}
|
||||
|
|
@ -167,6 +178,7 @@ public class TaskPlanEntity extends BaseEntity {
|
|||
", cycleValue='" + cycleValue + '\'' +
|
||||
", executeType='" + executeType + '\'' +
|
||||
", executeTime=" + executeTime +
|
||||
", duration=" + duration +
|
||||
", startDate=" + startDate +
|
||||
", endDate=" + endDate +
|
||||
", routeId=" + routeId +
|
||||
|
|
|
|||
|
|
@ -27,6 +27,7 @@ public class TaskPlanDTOConvert {
|
|||
dto.setStartDate(taskPlan.getStartDate());
|
||||
dto.setEndDate(taskPlan.getEndDate());
|
||||
dto.setExecuteTime(taskPlan.getExecuteTime());
|
||||
dto.setDuration(taskPlan.getDuration());
|
||||
dto.setRouteId(taskPlan.getRouteId());
|
||||
dto.setUavId(taskPlan.getUavId());
|
||||
dto.setStatus(taskPlan.getStatus());
|
||||
|
|
@ -51,6 +52,7 @@ public class TaskPlanDTOConvert {
|
|||
taskPlan.setStartDate(dto.getStartDate());
|
||||
taskPlan.setEndDate(dto.getEndDate());
|
||||
taskPlan.setExecuteTime(dto.getExecuteTime());
|
||||
taskPlan.setDuration(dto.getDuration());
|
||||
taskPlan.setRouteId(dto.getRouteId());
|
||||
taskPlan.setUavId(dto.getUavId());
|
||||
taskPlan.setStatus(dto.getStatus());
|
||||
|
|
|
|||
|
|
@ -42,6 +42,11 @@ public class TaskPlanDTO {
|
|||
/** 执行时间(仅在定义任务时有效) */
|
||||
private Date executeTime;
|
||||
|
||||
/**
|
||||
* 执行时长 秒
|
||||
*/
|
||||
private Integer duration;
|
||||
|
||||
/** 航线ID */
|
||||
private Long routeId;
|
||||
|
||||
|
|
@ -130,6 +135,14 @@ public class TaskPlanDTO {
|
|||
this.executeTime = executeTime;
|
||||
}
|
||||
|
||||
public Integer getDuration() {
|
||||
return duration;
|
||||
}
|
||||
|
||||
public void setDuration(Integer duration) {
|
||||
this.duration = duration;
|
||||
}
|
||||
|
||||
public Long getRouteId() {
|
||||
return routeId;
|
||||
}
|
||||
|
|
@ -182,6 +195,7 @@ public class TaskPlanDTO {
|
|||
", startDate=" + startDate +
|
||||
", endDate=" + endDate +
|
||||
", executeTime=" + executeTime +
|
||||
", duration=" + duration +
|
||||
", routeId=" + routeId +
|
||||
", uavId=" + uavId +
|
||||
", status=" + status +
|
||||
|
|
|
|||
|
|
@ -94,6 +94,15 @@ public class TaskPlanServiceImpl implements ITaskPlanService {
|
|||
task.setRouteId(taskPlan.getRouteId());
|
||||
task.setUavId(taskPlan.getUavId());
|
||||
task.setStartTime(taskPlan.getExecuteTime());
|
||||
|
||||
// 设置结束时间:开始时间 + 执行时长
|
||||
if (taskPlan.getExecuteTime() != null && taskPlan.getDuration() != null) {
|
||||
java.util.Calendar endTaskCalendar = java.util.Calendar.getInstance();
|
||||
endTaskCalendar.setTime(taskPlan.getExecuteTime());
|
||||
endTaskCalendar.add(java.util.Calendar.SECOND, taskPlan.getDuration());
|
||||
task.setEndTime(endTaskCalendar.getTime());
|
||||
}
|
||||
|
||||
task.setStatus(StatusEnum.PENDING); // 待执行
|
||||
task.setDescription("由任务计划自动创建");
|
||||
|
||||
|
|
@ -164,10 +173,15 @@ public class TaskPlanServiceImpl implements ITaskPlanService {
|
|||
taskCalendar.set(java.util.Calendar.SECOND, executeTimeCalendar.get(java.util.Calendar.SECOND));
|
||||
task.setStartTime(taskCalendar.getTime());
|
||||
|
||||
// 简单设置结束时间为开始时间后1小时(可根据实际需求调整)
|
||||
// java.util.Calendar endTaskCalendar = (java.util.Calendar) taskCalendar.clone();
|
||||
// endTaskCalendar.add(java.util.Calendar.HOUR_OF_DAY, 1);
|
||||
// task.setEndTime(endTaskCalendar.getTime());
|
||||
// 设置结束时间:开始时间 + 执行时长
|
||||
java.util.Calendar endTaskCalendar = (java.util.Calendar) taskCalendar.clone();
|
||||
if (taskPlan.getDuration() != null) {
|
||||
endTaskCalendar.add(java.util.Calendar.SECOND, taskPlan.getDuration());
|
||||
} else {
|
||||
// 如果没有设置执行时长,默认1小时
|
||||
endTaskCalendar.add(java.util.Calendar.HOUR_OF_DAY, 1);
|
||||
}
|
||||
task.setEndTime(endTaskCalendar.getTime());
|
||||
} else {
|
||||
// 如果没有设置执行时间,使用日历时间作为开始和结束时间
|
||||
task.setStartTime(calendar.getTime());
|
||||
|
|
|
|||
|
|
@ -0,0 +1,5 @@
|
|||
-- ----------------------------
|
||||
-- 添加任务计划执行时长字段
|
||||
-- ----------------------------
|
||||
ALTER TABLE task_plan
|
||||
ADD COLUMN duration INT(11) DEFAULT NULL COMMENT '执行时长(秒)' AFTER execute_time;
|
||||
|
|
@ -12,6 +12,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
<result property="cycleValue" column="cycle_value" />
|
||||
<result property="executeType" column="execute_type" />
|
||||
<result property="executeTime" column="execute_time" />
|
||||
<result property="duration" column="duration" />
|
||||
<result property="startDate" column="start_date" />
|
||||
<result property="endDate" column="end_date" />
|
||||
<result property="routeId" column="route_id" />
|
||||
|
|
@ -27,7 +28,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
|
||||
<sql id="selectTaskPlanVo">
|
||||
select id, plan_name, plan_type, cycle_type, cycle_value, execute_type,
|
||||
execute_time, start_date, end_date, route_id, uav_id, status,
|
||||
execute_time, duration, start_date, end_date, route_id, uav_id, status,
|
||||
description, create_by, create_time, update_by, update_time, remark
|
||||
from task_plan
|
||||
</sql>
|
||||
|
|
@ -73,6 +74,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
<if test="cycleValue != null and cycleValue != ''">cycle_value,</if>
|
||||
<if test="executeType != null and executeType != ''">execute_type,</if>
|
||||
<if test="executeTime != null">execute_time,</if>
|
||||
<if test="duration != null">duration,</if>
|
||||
<if test="startDate != null">start_date,</if>
|
||||
<if test="endDate != null">end_date,</if>
|
||||
<if test="routeId != null">route_id,</if>
|
||||
|
|
@ -90,6 +92,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
<if test="cycleValue != null and cycleValue != ''">#{cycleValue},</if>
|
||||
<if test="executeType != null and executeType != ''">#{executeType},</if>
|
||||
<if test="executeTime != null">#{executeTime},</if>
|
||||
<if test="duration != null">#{duration},</if>
|
||||
<if test="startDate != null">#{startDate},</if>
|
||||
<if test="endDate != null">#{endDate},</if>
|
||||
<if test="routeId != null">#{routeId},</if>
|
||||
|
|
@ -111,6 +114,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
<if test="cycleValue != null and cycleValue != ''">cycle_value = #{cycleValue},</if>
|
||||
<if test="executeType != null and executeType != ''">execute_type = #{executeType},</if>
|
||||
<if test="executeTime != null">execute_time = #{executeTime},</if>
|
||||
<if test="duration != null">duration = #{duration},</if>
|
||||
<if test="startDate != null">start_date = #{startDate},</if>
|
||||
<if test="endDate != null">end_date = #{endDate},</if>
|
||||
<if test="routeId != null">route_id = #{routeId},</if>
|
||||
|
|
|
|||
Loading…
Reference in New Issue