Commit f35e7e20 by xmh

任务管理服务:

1. <feat> 任务添加字段 alg_enabled
2. <fix> 新建任务时不再进行任务部署,必须手动
3. <fix> 更新任务时,如果任务处于未部署状态,则不进行部署
1 parent 8a933c23
......@@ -34,6 +34,8 @@ public class Task extends BaseModel {
private Integer status;
private String algEnabled;
private String runtimeConf;
private String scene;
......@@ -158,6 +160,14 @@ public class Task extends BaseModel {
this.status = status;
}
public String getAlgEnabled() {
return algEnabled;
}
public void setAlgEnabled(String algEnabled) {
this.algEnabled = algEnabled == null ? null : algEnabled.trim();
}
public String getRuntimeConf() {
return runtimeConf;
}
......
package com.viontech.fanxing.commons.model;
import com.viontech.fanxing.commons.base.BaseExample;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
public class TaskExample extends BaseExample {
......@@ -1056,6 +1058,76 @@ public class TaskExample extends BaseExample {
addCriterion("`task`.`status` not between", value1, value2, "status");
return (Criteria) this;
}
public Criteria andAlgEnabledIsNull() {
addCriterion("`task`.alg_enabled is null");
return (Criteria) this;
}
public Criteria andAlgEnabledIsNotNull() {
addCriterion("`task`.alg_enabled is not null");
return (Criteria) this;
}
public Criteria andAlgEnabledEqualTo(String value) {
addCriterion("`task`.alg_enabled =", value, "algEnabled");
return (Criteria) this;
}
public Criteria andAlgEnabledNotEqualTo(String value) {
addCriterion("`task`.alg_enabled <>", value, "algEnabled");
return (Criteria) this;
}
public Criteria andAlgEnabledGreaterThan(String value) {
addCriterion("`task`.alg_enabled >", value, "algEnabled");
return (Criteria) this;
}
public Criteria andAlgEnabledGreaterThanOrEqualTo(String value) {
addCriterion("`task`.alg_enabled >=", value, "algEnabled");
return (Criteria) this;
}
public Criteria andAlgEnabledLessThan(String value) {
addCriterion("`task`.alg_enabled <", value, "algEnabled");
return (Criteria) this;
}
public Criteria andAlgEnabledLessThanOrEqualTo(String value) {
addCriterion("`task`.alg_enabled <=", value, "algEnabled");
return (Criteria) this;
}
public Criteria andAlgEnabledLike(String value) {
addCriterion("`task`.alg_enabled like", value, "algEnabled");
return (Criteria) this;
}
public Criteria andAlgEnabledNotLike(String value) {
addCriterion("`task`.alg_enabled not like", value, "algEnabled");
return (Criteria) this;
}
public Criteria andAlgEnabledIn(List<String> values) {
addCriterion("`task`.alg_enabled in", values, "algEnabled");
return (Criteria) this;
}
public Criteria andAlgEnabledNotIn(List<String> values) {
addCriterion("`task`.alg_enabled not in", values, "algEnabled");
return (Criteria) this;
}
public Criteria andAlgEnabledBetween(String value1, String value2) {
addCriterion("`task`.alg_enabled between", value1, value2, "algEnabled");
return (Criteria) this;
}
public Criteria andAlgEnabledNotBetween(String value1, String value2) {
addCriterion("`task`.alg_enabled not between", value1, value2, "algEnabled");
return (Criteria) this;
}
}
public static class ColumnContainer extends ColumnContainerBase {
......@@ -1138,5 +1210,10 @@ public class TaskExample extends BaseExample {
addColumnStr("`task`.`status` as `task_status` ");
return (ColumnContainer) this;
}
public ColumnContainer hasAlgEnabledColumn() {
addColumnStr("`task`.alg_enabled as task_alg_enabled ");
return (ColumnContainer) this;
}
}
}
\ No newline at end of file
......@@ -187,6 +187,15 @@ public class TaskVoBase extends Task implements VoInterface<Task> {
private Integer status_lte;
@JsonIgnore
private Boolean algEnabled_null;
@JsonIgnore
private ArrayList<String> algEnabled_arr;
@JsonIgnore
private String algEnabled_like;
@JsonIgnore
private Boolean runtimeConf_null;
@JsonIgnore
......@@ -906,6 +915,44 @@ public class TaskVoBase extends Task implements VoInterface<Task> {
this.getModel().setStatus(status);
}
public Boolean getAlgEnabled_null() {
return algEnabled_null;
}
public void setAlgEnabled_null(Boolean algEnabled_null) {
this.algEnabled_null = algEnabled_null;
}
public ArrayList<String> getAlgEnabled_arr() {
return algEnabled_arr;
}
public void setAlgEnabled_arr(ArrayList<String> algEnabled_arr) {
this.algEnabled_arr = algEnabled_arr;
}
public String getAlgEnabled_like() {
return algEnabled_like;
}
public void setAlgEnabled_like(String algEnabled_like) {
this.algEnabled_like = algEnabled_like;
}
public String getAlgEnabled() {
if(getModel() == null ){
throw new RuntimeException("model is null");
}
return this.getModel().getAlgEnabled();
}
public void setAlgEnabled(String algEnabled) {
if(getModel() == null ){
throw new RuntimeException("model is null");
}
this.getModel().setAlgEnabled(algEnabled);
}
public Boolean getRuntimeConf_null() {
return runtimeConf_null;
}
......
......@@ -2,12 +2,13 @@ package com.viontech.fanxing.task.controller.base;
import com.viontech.fanxing.commons.base.BaseController;
import com.viontech.fanxing.commons.base.BaseExample;
import com.viontech.fanxing.commons.base.BaseMapper;
import com.viontech.fanxing.commons.base.BaseService;
import com.viontech.fanxing.commons.model.Task;
import com.viontech.fanxing.commons.model.TaskExample;
import com.viontech.fanxing.commons.vo.TaskVo;
import com.viontech.fanxing.task.mapper.TaskMapper;
import com.viontech.fanxing.task.service.adapter.TaskService;
import javax.annotation.Resource;
public abstract class TaskBaseController extends BaseController<Task, TaskVo> {
......@@ -260,6 +261,22 @@ public abstract class TaskBaseController extends BaseController<Task, TaskVo> {
if(taskVo.getStatus_lte() != null) {
criteria.andStatusLessThanOrEqualTo(taskVo.getStatus_lte());
}
if(taskVo.getAlgEnabled() != null) {
criteria.andAlgEnabledEqualTo(taskVo.getAlgEnabled());
}
if(taskVo.getAlgEnabled_null() != null) {
if(taskVo.getAlgEnabled_null().booleanValue()) {
criteria.andAlgEnabledIsNull();
} else {
criteria.andAlgEnabledIsNotNull();
}
}
if(taskVo.getAlgEnabled_arr() != null) {
criteria.andAlgEnabledIn(taskVo.getAlgEnabled_arr());
}
if(taskVo.getAlgEnabled_like() != null) {
criteria.andAlgEnabledLike(taskVo.getAlgEnabled_like());
}
return taskExample;
}
......
......@@ -17,6 +17,7 @@
<result column="task_stream_type" property="streamType" />
<result column="task_create_time" property="createTime" />
<result column="task_status" property="status" />
<result column="task_alg_enabled" property="algEnabled" />
</resultMap>
<resultMap id="BaseResultMap" type="com.viontech.fanxing.commons.model.Task" extends="BaseResultMapRoot" />
<resultMap id="ResultMapWithBLOBs" type="com.viontech.fanxing.commons.model.Task" extends="BaseResultMap" >
......@@ -86,7 +87,8 @@
`task`.resource_need as task_resource_need, `task`.priority as task_priority, `task`.store_config_id as task_store_config_id,
`task`.va_type as task_va_type, `task`.runtime_type as task_runtime_type, `task`.device_unid as task_device_unid,
`task`.channel_unid as task_channel_unid, `task`.stream_path as task_stream_path,
`task`.stream_type as task_stream_type, `task`.create_time as task_create_time, `task`.`status` as `task_status`
`task`.stream_type as task_stream_type, `task`.create_time as task_create_time, `task`.`status` as `task_status`,
`task`.alg_enabled as task_alg_enabled
</sql>
<sql id="Base_Column_List" >
<if test="!(_parameter.getClass().getSimpleName() == 'TaskExample')" >
......@@ -169,14 +171,14 @@
resource_need, priority, store_config_id,
va_type, runtime_type, device_unid,
channel_unid, stream_path, stream_type,
create_time, `status`, runtime_conf,
scene)
create_time, `status`, alg_enabled,
runtime_conf, scene)
values (#{unid,jdbcType=VARCHAR}, #{name,jdbcType=VARCHAR}, #{algType,jdbcType=VARCHAR},
#{resourceNeed,jdbcType=REAL}, #{priority,jdbcType=INTEGER}, #{storeConfigId,jdbcType=BIGINT},
#{vaType,jdbcType=VARCHAR}, #{runtimeType,jdbcType=INTEGER}, #{deviceUnid,jdbcType=VARCHAR},
#{channelUnid,jdbcType=VARCHAR}, #{streamPath,jdbcType=VARCHAR}, #{streamType,jdbcType=INTEGER},
#{createTime,jdbcType=TIMESTAMP}, #{status,jdbcType=INTEGER}, #{runtimeConf,jdbcType=LONGVARCHAR},
#{scene,jdbcType=LONGVARCHAR})
#{createTime,jdbcType=TIMESTAMP}, #{status,jdbcType=INTEGER}, #{algEnabled,jdbcType=VARCHAR},
#{runtimeConf,jdbcType=LONGVARCHAR}, #{scene,jdbcType=LONGVARCHAR})
</insert>
<insert id="insertSelective" parameterType="com.viontech.fanxing.commons.model.Task" useGeneratedKeys="true" keyProperty="id" keyColumn="id" >
insert into `s_task`
......@@ -223,6 +225,9 @@
<if test="status != null" >
`status`,
</if>
<if test="algEnabled != null" >
alg_enabled,
</if>
<if test="runtimeConf != null" >
runtime_conf,
</if>
......@@ -273,6 +278,9 @@
<if test="status != null" >
#{status,jdbcType=INTEGER},
</if>
<if test="algEnabled != null" >
#{algEnabled,jdbcType=VARCHAR},
</if>
<if test="runtimeConf != null" >
#{runtimeConf,jdbcType=LONGVARCHAR},
</if>
......@@ -335,6 +343,9 @@
<if test="record.status != null" >
`status` = #{record.status,jdbcType=INTEGER},
</if>
<if test="record.algEnabled != null" >
alg_enabled = #{record.algEnabled,jdbcType=VARCHAR},
</if>
<if test="record.runtimeConf != null" >
runtime_conf = #{record.runtimeConf,jdbcType=LONGVARCHAR},
</if>
......@@ -363,6 +374,7 @@
`task`.stream_type = #{record.streamType,jdbcType=INTEGER},
`task`.create_time = #{record.createTime,jdbcType=TIMESTAMP},
`task`.`status` = #{record.status,jdbcType=INTEGER},
`task`.alg_enabled = #{record.algEnabled,jdbcType=VARCHAR},
`task`.runtime_conf = #{record.runtimeConf,jdbcType=LONGVARCHAR},
`task`.scene = #{record.scene,jdbcType=LONGVARCHAR}
<if test="_parameter != null" >
......@@ -385,7 +397,8 @@
stream_path = #{record.streamPath,jdbcType=VARCHAR},
stream_type = #{record.streamType,jdbcType=INTEGER},
create_time = #{record.createTime,jdbcType=TIMESTAMP},
`status` = #{record.status,jdbcType=INTEGER}
`status` = #{record.status,jdbcType=INTEGER},
alg_enabled = #{record.algEnabled,jdbcType=VARCHAR}
<if test="_parameter != null" >
<include refid="Update_By_Example_Where_Clause" />
</if>
......@@ -435,6 +448,9 @@
<if test="status != null" >
`status` = #{status,jdbcType=INTEGER},
</if>
<if test="algEnabled != null" >
alg_enabled = #{algEnabled,jdbcType=VARCHAR},
</if>
<if test="runtimeConf != null" >
runtime_conf = #{runtimeConf,jdbcType=LONGVARCHAR},
</if>
......@@ -460,6 +476,7 @@
stream_type = #{streamType,jdbcType=INTEGER},
create_time = #{createTime,jdbcType=TIMESTAMP},
`status` = #{status,jdbcType=INTEGER},
alg_enabled = #{algEnabled,jdbcType=VARCHAR},
runtime_conf = #{runtimeConf,jdbcType=LONGVARCHAR},
scene = #{scene,jdbcType=LONGVARCHAR}
where id = #{id,jdbcType=BIGINT}
......@@ -479,7 +496,8 @@
stream_path = #{streamPath,jdbcType=VARCHAR},
stream_type = #{streamType,jdbcType=INTEGER},
create_time = #{createTime,jdbcType=TIMESTAMP},
`status` = #{status,jdbcType=INTEGER}
`status` = #{status,jdbcType=INTEGER},
alg_enabled = #{algEnabled,jdbcType=VARCHAR}
where id = #{id,jdbcType=BIGINT}
</update>
</mapper>
\ No newline at end of file
......@@ -13,5 +13,5 @@ public interface TaskService extends BaseService<Task> {
void updateStatus(Long id, Integer status);
void startTask(Long id) throws Exception;
void startTask(Long id);
}
\ No newline at end of file
......@@ -31,10 +31,6 @@ public class TaskServiceImpl extends BaseServiceImpl<Task> implements TaskServic
public TaskVo addTask(Task task) {
task = insertSelective(task);
task = selectByPrimaryKey(task.getId());
if (StringUtils.isNotBlank(task.getScene()) && task.getStoreConfigId() != null) {
taskDataService.addTask(task);
}
return new TaskVo(task);
}
......@@ -44,7 +40,7 @@ public class TaskServiceImpl extends BaseServiceImpl<Task> implements TaskServic
updateByPrimaryKeySelective(task);
task = selectByPrimaryKey(task.getId());
if (StringUtils.isNotBlank(task.getScene()) && task.getStoreConfigId() != null) {
if (StringUtils.isNotBlank(task.getScene()) && task.getStoreConfigId() != null && !task.getStatus().equals(TaskStatus.AWAIT.val)) {
taskDataService.updateTask(task);
}
return new TaskVo(task);
......@@ -69,7 +65,7 @@ public class TaskServiceImpl extends BaseServiceImpl<Task> implements TaskServic
@Override
@Transactional(rollbackFor = Exception.class)
public void startTask(Long id) throws Exception {
public void startTask(Long id) {
Task task = selectByPrimaryKey(id);
if (StringUtils.isBlank(task.getScene())) {
throw new IllegalArgumentException("场景配置为空,无法执行");
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!