Commit f289f914 authored by mcb's avatar mcb
parents 8b29c23c e97974dc
......@@ -11,4 +11,23 @@ import io.swagger.annotations.ApiModel;
@ApiModel(value = "任务历史版本Dto", description = "任务历史版本Dto")
public class DmpDevelopTaskHistoryDto extends DmpDevelopTaskHistory {
private String name;
private Integer projectId;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public Integer getProjectId() {
return projectId;
}
public void setProjectId(Integer projectId) {
this.projectId = projectId;
}
}
......@@ -203,7 +203,8 @@ public abstract class AbstractCommandExecutor {
logger.info("process start, process id is: {}", processId);
// if timeout occurs, exit directly
long remainTime = getRemaintime();
//long remainTime = getRemaintime();
long remainTime = 60;
// waiting for the run to finish
boolean status = process.waitFor(remainTime, TimeUnit.SECONDS);
......
......@@ -98,6 +98,7 @@ public class ShellCommandExecutor extends AbstractCommandExecutor {
if (taskExecutionContext.getEnvFile() != null) {
sb.append("call ").append(taskExecutionContext.getEnvFile()).append("\n");
}
sb.append(execCommand);
} else {
sb.append("#!/bin/sh\n");
sb.append("BASEDIR=$(cd `dirname $0`; pwd)\n");
......@@ -105,9 +106,11 @@ public class ShellCommandExecutor extends AbstractCommandExecutor {
if (taskExecutionContext.getEnvFile() != null) {
sb.append("source ").append(taskExecutionContext.getEnvFile()).append("\n");
}
sb.append("dos2unix"+" "+execCommand+"\n");
sb.append(execCommand);
}
sb.append(execCommand);
logger.info("command : {}", sb.toString());
// write data to file
......
......@@ -160,27 +160,34 @@ public class ProcessService {
String script = "";
String taskAppId = "";
String taskName = dmpDevelopTaskDto.getName();
String taskType = dmpDevelopTaskDto.getTaskType();//任务类型
if (taskType.equals(CommConstant.TASK_TYPE_DEVSHELL)) {
jobType = JobType.shell;
script = dmpDevelopTaskDto.getScript();
taskAppId = dmpDevelopTaskDto.getName();
taskAppId = taskName;
}else if (taskType.equals(CommConstant.TASK_TYPE_DEVSQL)) {
jobType = JobType.sql;
script = dmpDevelopTaskDto.getScript();
taskAppId = dmpDevelopTaskDto.getName();
taskAppId = taskName;
}else if (taskType.equals(CommConstant.TASK_TYPE_OFFLINE)) {
jobType = JobType.sync;
script = dmpDevelopTaskDto.getScript();
taskAppId = dmpDevelopTaskDto.getName();
taskAppId = taskName;
}else if (taskType.equals(CommConstant.TASK_TYPE_DEVELOP)) {
String scriptStr = dmpDevelopTaskDto.getScript();
JSONObject scriptObj = JSONObject.parseObject(scriptStr);
JSONArray array = scriptObj.getJSONArray("nodes");
for (int i = 0; i < array.size(); i++) {
JSONObject jObject = array.getJSONObject(i);
String taskJobType = jObject.getString("taskType");
String lable = jObject.getString("label");
if (jobId.equals(lable)) {
String comparLabel = lable;
if (!CommConstant.WORK_TYPE_START.equals(taskJobType) && !CommConstant.WORK_TYPE_STOP.equals(taskJobType)) {
comparLabel = lable+"_"+taskName;
}
if (jobId.equals(comparLabel)) {
jobType = JobType.valueOf(jObject.getString("taskType"));//job类型
script = jObject.toJSONString();
taskAppId = lable;
......
......@@ -33,28 +33,31 @@
<resultMap id="BaseDtoResultMap" type="com.jz.dmp.cmdexectool.controller.bean.DmpDevelopTaskHistoryDto" extends="BaseResultMap">
<!-- /*$BaseDtoResultMapContent$*/ -->
<result column="name" property="name" jdbcType="VARCHAR" />
<result column="project_id" property="projectId" jdbcType="INTEGER" />
</resultMap>
<sql id="Base_Column_List">
id, task_id, tree_id, datasource_id, task_type,
type, schedule_type, is_submit, task_desc, script,
flow_header, flow_json, version, is_gziped, task_data_status,
task_create_user_id, task_create_time, task_update_user_id, task_update_time, remark,
data_status, create_user_id, create_time, update_user_id, update_time
history.id, history.task_id, history.tree_id, history.datasource_id, history.task_type,
history.type, history.schedule_type, history.is_submit, history.task_desc, history.script,
history.flow_header, history.flow_json, history.version, history.is_gziped, history.task_data_status,
history.task_create_user_id, history.task_create_time, history.task_update_user_id, history.task_update_time, history.remark,
history.data_status, history.create_user_id, history.create_time, history.update_user_id, history.update_time
</sql>
<sql id="BaseDto_Column_List">
<include refid="Base_Column_List" />
<!-- /*$BaseDtoColumnListContent$*/ -->
, tree.project_id, tree.name
</sql>
<!-- 根据主键查询任务历史版本 -->
<select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.String">
select
<include refid="Base_Column_List" />
from dmp_develop_task_history
where id = #{id,jdbcType=INTEGER}
AND data_status='1'
from dmp_develop_task_history history
where history.id = #{id,jdbcType=INTEGER}
AND history.data_status='1'
</select>
<!-- 根据主键删除任务历史版本 -->
......@@ -581,94 +584,94 @@
<select id="findList" resultMap="BaseDtoResultMap">
SELECT
<include refid="BaseDto_Column_List"/>
FROM dmp_develop_task_history
FROM dmp_develop_task_history history LEFT JOIN dmp_navigation_tree tree ON history.tree_id=tree.id
<where>
<if test="id != null" >
AND id = #{id,jdbcType=INTEGER}
AND history.id = #{id,jdbcType=INTEGER}
</if>
<if test="taskId != null" >
AND task_id = #{taskId,jdbcType=INTEGER}
AND history.task_id = #{taskId,jdbcType=INTEGER}
</if>
<if test="treeId != null" >
AND tree_id = #{treeId,jdbcType=INTEGER}
AND history.tree_id = #{treeId,jdbcType=INTEGER}
</if>
<if test="datasourceId != null" >
AND datasource_id = #{datasourceId,jdbcType=INTEGER}
AND history.datasource_id = #{datasourceId,jdbcType=INTEGER}
</if>
<if test="taskType != null" >
AND task_type = #{taskType,jdbcType=CHAR}
AND history.task_type = #{taskType,jdbcType=CHAR}
</if>
<if test="type != null" >
AND type = #{type,jdbcType=CHAR}
AND history.type = #{type,jdbcType=CHAR}
</if>
<if test="scheduleType != null" >
AND schedule_type = #{scheduleType,jdbcType=CHAR}
AND history.schedule_type = #{scheduleType,jdbcType=CHAR}
</if>
<if test="isSubmit != null" >
AND is_submit = #{isSubmit,jdbcType=CHAR}
AND history.is_submit = #{isSubmit,jdbcType=CHAR}
</if>
<if test="taskDesc != null" >
AND task_desc = #{taskDesc,jdbcType=VARCHAR}
AND history.task_desc = #{taskDesc,jdbcType=VARCHAR}
</if>
<if test="script != null" >
AND script = #{script,jdbcType=BLOB, typeHandler=com.jz.dmp.cmdexectool.common.persistence.CBTHandler}
AND history.script = #{script,jdbcType=BLOB, typeHandler=com.jz.dmp.cmdexectool.common.persistence.CBTHandler}
</if>
<if test="flowHeader != null" >
AND flow_header = #{flowHeader,jdbcType=VARCHAR}
AND history.flow_header = #{flowHeader,jdbcType=VARCHAR}
</if>
<if test="flowJson != null" >
AND flow_json = #{flowJson,jdbcType=BLOB, typeHandler=com.jz.dmp.cmdexectool.common.persistence.CBTHandler}
AND history.flow_json = #{flowJson,jdbcType=BLOB, typeHandler=com.jz.dmp.cmdexectool.common.persistence.CBTHandler}
</if>
<if test="version != null" >
AND version = #{version,jdbcType=VARCHAR}
AND history.version = #{version,jdbcType=VARCHAR}
</if>
<if test="isGziped != null" >
AND is_gziped = #{isGziped,jdbcType=VARCHAR}
AND history.is_gziped = #{isGziped,jdbcType=VARCHAR}
</if>
<if test="taskDataStatus != null" >
AND task_data_status = #{taskDataStatus,jdbcType=CHAR}
AND history.task_data_status = #{taskDataStatus,jdbcType=CHAR}
</if>
<if test="taskCreateUserId != null" >
AND task_create_user_id = #{taskCreateUserId,jdbcType=CHAR}
AND history.task_create_user_id = #{taskCreateUserId,jdbcType=CHAR}
</if>
<if test="taskCreateTimeStart != null" >
AND task_create_time >= #{taskCreateTimeStart,jdbcType=TIMESTAMP}
AND history.task_create_time >= #{taskCreateTimeStart,jdbcType=TIMESTAMP}
</if>
<if test="taskCreateTimeEnd != null" >
AND task_create_time <![CDATA[ <= ]]> #{taskCreateTimeEnd,jdbcType=TIMESTAMP}
AND history.task_create_time <![CDATA[ <= ]]> #{taskCreateTimeEnd,jdbcType=TIMESTAMP}
</if>
<if test="taskUpdateUserId != null" >
AND task_update_user_id = #{taskUpdateUserId,jdbcType=CHAR}
AND history.task_update_user_id = #{taskUpdateUserId,jdbcType=CHAR}
</if>
<if test="taskUpdateTimeStart != null" >
AND task_update_time >= #{taskUpdateTimeStart,jdbcType=TIMESTAMP}
AND history.task_update_time >= #{taskUpdateTimeStart,jdbcType=TIMESTAMP}
</if>
<if test="taskUpdateTimeEnd != null" >
AND task_update_time <![CDATA[ <= ]]> #{taskUpdateTimeEnd,jdbcType=TIMESTAMP}
AND history.task_update_time <![CDATA[ <= ]]> #{taskUpdateTimeEnd,jdbcType=TIMESTAMP}
</if>
<if test="remark != null" >
AND remark = #{remark,jdbcType=VARCHAR}
AND history.remark = #{remark,jdbcType=VARCHAR}
</if>
<if test="dataStatus != null" >
AND data_status = #{dataStatus,jdbcType=CHAR}
AND history.data_status = #{dataStatus,jdbcType=CHAR}
</if>
<if test="createUserId != null" >
AND create_user_id = #{createUserId,jdbcType=INTEGER}
AND history.create_user_id = #{createUserId,jdbcType=INTEGER}
</if>
<if test="createTimeStart != null" >
AND create_time >= #{createTimeStart,jdbcType=TIMESTAMP}
AND history.create_time >= #{createTimeStart,jdbcType=TIMESTAMP}
</if>
<if test="createTimeEnd != null" >
AND create_time <![CDATA[ <= ]]> #{createTimeEnd,jdbcType=TIMESTAMP}
AND history.create_time <![CDATA[ <= ]]> #{createTimeEnd,jdbcType=TIMESTAMP}
</if>
<if test="updateUserId != null" >
AND update_user_id = #{updateUserId,jdbcType=INTEGER}
AND history.update_user_id = #{updateUserId,jdbcType=INTEGER}
</if>
<if test="updateTimeStart != null" >
AND update_time >= #{updateTimeStart,jdbcType=TIMESTAMP}
AND history.update_time >= #{updateTimeStart,jdbcType=TIMESTAMP}
</if>
<if test="updateTimeEnd != null" >
AND update_time <![CDATA[ <= ]]> #{updateTimeEnd,jdbcType=TIMESTAMP}
AND history.update_time <![CDATA[ <= ]]> #{updateTimeEnd,jdbcType=TIMESTAMP}
</if>
</where>
</select>
......@@ -677,9 +680,9 @@
<select id="findById" resultMap="BaseDtoResultMap" parameterType="java.lang.String">
select
<include refid="BaseDto_Column_List" />
from dmp_develop_task_history
where id = #{id,jdbcType=INTEGER}
AND data_status='1'
from dmp_develop_task_history history LEFT JOIN dmp_navigation_tree tree ON history.tree_id=tree.id
where history.id = #{id,jdbcType=INTEGER}
AND history.data_status='1'
</select>
<!-- 根据主键批量删除任务历史版本 -->
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment