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