Authored by fu

任务执行详情

... ... @@ -3,6 +3,10 @@ package com.yoho.jobs.dal;
*
*/
import java.util.List;
import org.apache.ibatis.annotations.Param;
import com.yoho.jobs.dal.domain.ProcessResultVO;
/**
... ... @@ -10,9 +14,10 @@ import com.yoho.jobs.dal.domain.ProcessResultVO;
*
*/
public interface IJobResultMapper {
public void insertJob(ProcessResultVO jobResult);
// public ProcessResult selectJob(String jobName,String module);
public List<ProcessResultVO> selectJobs(@Param("jobName") String jobName, @Param("module") String module,
@Param("limit") int limit);
}
... ...
... ... @@ -4,9 +4,11 @@
package com.yoho.jobs.dal.domain;
import java.io.Serializable;
import java.util.Date;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
/**
* @author yanzhang.fu
... ... @@ -14,6 +16,7 @@ import lombok.Setter;
*/
@Getter
@Setter
@ToString
public class ProcessResultVO implements Serializable{
... ... @@ -103,19 +106,21 @@ public class ProcessResultVO implements Serializable{
* 0:单次任务 1-周期性任务
*/
private int activeMode;
@Override
public String toString() {
StringBuffer sb = new StringBuffer();
sb.append(" ProcessResult is [ code=");
sb.append(code);
sb.append(", beginTime=");
sb.append(beginTime);
sb.append(" ,endTime=");
sb.append(endTime);
sb.append(", message=");
sb.append(message);
sb.append("]");
return sb.toString();
}
private Date recordDate;
// @Override
// public String toString() {
// StringBuffer sb = new StringBuffer();
// sb.append(" ProcessResult is [ code=");
// sb.append(code);
// sb.append(", beginTime=");
// sb.append(beginTime);
// sb.append(" ,endTime=");
// sb.append(endTime);
// sb.append(", message=");
// sb.append(message);
// sb.append("]");
// return sb.toString();
// }
}
... ...
... ... @@ -17,13 +17,14 @@
jdbcType="VARCHAR" />
<result column="context" property="context" jdbcType="VARCHAR" />
<result column="activeMode" property="activeMode" jdbcType="INTEGER" />
<result column="recordDate" property="recordDate" jdbcType="TIMESTAMP" />
</resultMap>
<sql id="Base_Column_List">
code, message, beginTime, endTime, jobName, jobGroup,
processor,
jobType, processIp, module, cronExpression, context,
activeMode
activeMode,recordDate
</sql>
<insert id="insertJob" parameterType="com.yoho.jobs.dal.domain.ProcessResultVO">
... ... @@ -33,13 +34,22 @@
processor,
jobType, processIp, module, cronExpression,
context,
activeMode)values(#{code,jdbcType=VARCHAR},
activeMode , recordDate)values(#{code,jdbcType=VARCHAR},
#{message,jdbcType=VARCHAR},#{beginTime,jdbcType=VARCHAR},#{endTime,jdbcType=VARCHAR},
#{jobName,jdbcType=VARCHAR},#{jobGroup,jdbcType=VARCHAR},#{processor,jdbcType=VARCHAR},
#{jobType,jdbcType=INTEGER},#{processIp,jdbcType=VARCHAR},#{module,jdbcType=VARCHAR},
#{cronExpression,jdbcType=VARCHAR},#{context,jdbcType=VARCHAR},#{activeMode,jdbcType=INTEGER}
#{cronExpression,jdbcType=VARCHAR},#{context,jdbcType=VARCHAR},#{activeMode,jdbcType=INTEGER},#{recordDate,jdbcType=TIMESTAMP}
)
</insert>
<select id="selectJobs" resultMap="BaseResultMap">
select
<include refid="Base_Column_List"/>
from job_run_log
where jobName= #{jobName} AND module = #{module} order by recordDate desc limit #{limit}
</select>
</mapper>
\ No newline at end of file
... ...
... ... @@ -2,3 +2,4 @@ web.context=jobs
zkAddress=172.16.6.85:2181
web.port=8080
yoho.logs.level=debug
limitrecord=5
... ...
<div id="showDetailDiv">
<div id="showDetailTable"></div>
</div>
<meta charset="utf-8">
<link href="../css/bootstrap.css" rel="stylesheet">
<script src="../js/jquery-1.12.0.min.js" charset="UTF-8"
type="text/javascript"></script>
<script src="../js/bootstrap.table.js" charset="UTF-8"
type="text/javascript"></script>
<script src="../js/bootstrap.dialog.js" charset="UTF-8"
type="text/javascript"></script>
<script src="../js/bootstrap.pagination.js" charset="UTF-8"
type="text/javascript"></script>
<script src="../js/bootstrap.js" charset="UTF-8" type="text/javascript"></script>
<script src="../js/bootstrap.panel.js" charset="UTF-8"
type="text/javascript"></script>
<script>
$(function() {
var args = new Object();
args = GetUrlParms();
var jobname1 = args["jobname"];
var module1 = args["module"];
var currentPage = 1;
var panelStyle = "panel-primary";
var queryData = {
}
$("#showDetailDiv #showDetailTable").table(
{
url : "/jobs/jobmanager/getdetailjob.do",
queryParams : {
"jobName" : jobname1,
"module" : module1
},
dataType : "json",
type : "POST",
contentType : "application/json; charset=utf-8",
currentPage : currentPage,
title : "任务执行情况",
panelClass : panelStyle,
striped : true,
pagination : true,
pageSize : 10,
loadFilter : function(data) {
return data.data;
},
columns : [
{
title : "任务名称",
field : "jobName"
},
{
title : "任务所属组",
field : "jobGroup"
},
{
title : "任务所属模块",
field : "module"
},
{
title : "任务执行表达式",
field : "cronExpression"
},
{
title : "任务执行器",
field : "processor"
},
{
title : "任务执行入参",
field : "context"
},
{
title : "方式",
field : "activeMode",
formatter : function(value, rowData, rowIndex) {
if (value == 0)
return "单次";
else if (value == 1)
return "循环";
else
return "";
}
},
{
title : "执行IP",
field : "processIp"
},
{
title : "执行状态",
field : "status",
formatter : function(value, rowData, RowIndex) {
if (value == 1)
return "执行中";
else if (value == 0)
return "停止";
else
return "";
}
},
{
title : "执行结果",
field : "code"
},
{
title : "开始时间",
field : "beginTime"
},
{
title : "结束时间",
field : "endTime"
},
{
title : "附加信息",
field : "message"
},
{
title : "操作",
formatter : function(value, rowData, rowIndex) {
var div = $("<div>");
if (rowData.status == 0) {//已暂停,可以开启
var openBtn = $("<button>").addClass(
"btn btn-xs btn-success").html(
"开启").appendTo(div);
div.append("&nbsp;");
openBtn.click(function() {//开启变为待执行状态
changeState(rowData, 1, this,
"确定开启吗", "确定开启改任务么");
});
}
if (rowData.status == 1) {//执行状态,可以停止
var stopBtn = $("<button>").addClass(
"btn btn-xs btn-success").html(
"停止").appendTo(div);
stopBtn.click(function() {
changeState(rowData, 0, this,
"确定停止吗", "确认停止该任务么");
});
div.append("&nbsp;");
}
if (rowData.status == 1) {//执行中只可以查看
var editBtn = $("<button>").addClass(
"btn btn-xs btn-success").html(
"查看").appendTo(div);
editBtn.click(function() {
showDetailJob(rowData);
});
} else {//非执行中状态可以进行其他部分操作
var editBtn = $("<button>").addClass(
"btn btn-xs btn-success").html(
"编辑").appendTo(div);
editBtn.click(function() {
editJob(rowData);
});
div.append("&nbsp;");
div.append("&nbsp;");
}
return div;
}
} ]
});
});
function GetUrlParms() {
var args = new Object();
var query = location.search.substring(1);//获取查询串
var pairs = query.split("&");//在逗号处断开
for (var i = 0; i < pairs.length; i++) {
var pos = pairs[i].indexOf('=');//查找name=value
if (pos == -1)
continue;//如果没有找到就跳过
var argname = pairs[i].substring(0, pos);//提取name
var value = pairs[i].substring(pos + 1);//提取value
args[argname] = unescape(value);//存为属性
}
return args;
}
</script>
</div>
... ...
<div id="jobInfoDiv">
<div id="jobInfoListTable"></div>
<div id="jobCreateJobBtm" >
<div id="jobCreateJobBtm">
<button id="crtbtn" onclick="showCreatePage()">创建任务</button>
</div>
<div id="jobCreateJobDiv">
</div>
<div id="jobCreateJobDiv"></div>
</div>
<meta charset="utf-8">
<link href="../css/bootstrap.css" rel="stylesheet">
<script src="../js/jquery-1.12.0.min.js" charset="UTF-8" type="text/javascript"></script>
<script src="../js/bootstrap.table.js" charset="UTF-8" type="text/javascript"></script>
<script src="../js/bootstrap.dialog.js" charset="UTF-8" type="text/javascript"></script>
<script src="../js/bootstrap.pagination.js" charset="UTF-8" type="text/javascript"></script>
<script src="../js/jquery-1.12.0.min.js" charset="UTF-8"
type="text/javascript"></script>
<script src="../js/bootstrap.table.js" charset="UTF-8"
type="text/javascript"></script>
<script src="../js/bootstrap.dialog.js" charset="UTF-8"
type="text/javascript"></script>
<script src="../js/bootstrap.pagination.js" charset="UTF-8"
type="text/javascript"></script>
<script src="../js/bootstrap.js" charset="UTF-8" type="text/javascript"></script>
<script src="../js/bootstrap.panel.js" charset="UTF-8" type="text/javascript"></script>
<script src="../js/bootstrap.panel.js" charset="UTF-8"
type="text/javascript"></script>
<script>
$(function() {
//设置路径导航
//全局用来html传递参数使用
//var paramObj = {};
$("#jobCreateJobDiv").hide();
var activeId = 0;
var activeName = "";
var activeMode = 0;
var status = 0;
var groupId = 0;
var startTime = "";
var endTime = "";
var pushType = 0;
var currentPage = 1;
//全局的panel的样式
var panelStyle = "panel-primary";
$("#jobInfoDiv #jobInfoListTable")
.table(
{
url : "/jobs/jobmanager/showalljob.do",
queryParams : {
$("#jobInfoDiv #jobInfoListTable").table(
{
url : "/jobs/jobmanager/showalljob.do",
queryParams : {
},
currentPage : currentPage,
title : "任务列表",
panelClass : panelStyle,
striped : true,
pagination : true,
pageSize : 10,
loadFilter : function(data) {
return data.data;
},
columns : [
{
title : "任务名称",
field : "jobName"
},
currentPage : currentPage,
title : "任务列表",
panelClass : panelStyle,
striped : true,
pagination : true,
pageSize : 10,
loadFilter : function(data) {
return data.data;
{
title : "任务所属组",
field : "jobGroup"
},
{
title : "任务所属模块",
field : "module"
},
{
title : "任务执行表达式",
field : "cronExpression"
},
{
title : "任务执行器",
field : "processor"
},
{
title : "任务执行入参",
field : "context"
},
columns : [
{
title : "任务名称",
field : "jobName"
},
{
title : "任务所属组",
field : "jobGroup"
},
{
title : "任务所属模块",
field : "module"
},
{
title : "任务执行表达式",
field : "cronExpression"
},
{
title : "任务执行器",
field : "processor"
},
{
title : "任务执行入参",
field : "context"
},
{
title : "方式",
field : "activeMode",
formatter : function(value, rowData,
rowIndex) {
if (value == 0)
return "单次";
else if (value == 1)
return "循环";
else
return "";
}
},
{
title : "执行IP",
field : "processIp"
},
{
title : "执行状态",
field : "status",
formatter : function(value, rowData,
RowIndex) {
if (value == 1)
return "执行中";
else if (value == 0)
return "停止";
else
return "";
}
},
{
title : "操作",
formatter : function(value, rowData,
rowIndex) {
var div = $("<div>");
{
title : "方式",
field : "activeMode",
formatter : function(value, rowData, rowIndex) {
if (value == 0)
return "单次";
else if (value == 1)
return "循环";
else
return "";
}
},
{
title : "执行IP",
field : "processIp"
},
{
title : "执行状态",
field : "status",
formatter : function(value, rowData, RowIndex) {
if (value == 1)
return "执行中";
else if (value == 0)
return "停止";
else
return "";
}
},
{
title : "操作",
formatter : function(value, rowData, rowIndex) {
var div = $("<div>");
if (rowData.status == 0) {//已暂停,可以开启
var openBtn = $("<button>")
.addClass(
"btn btn-xs btn-success")
.html("开启").appendTo(
div);
div.append("&nbsp;");
openBtn.click(function() {//开启变为待执行状态
changeState(rowData, 1,
this, "确定开启吗",
"确定开启改任务么");
});
}
if (rowData.status == 1) {//执行状态,可以停止
var stopBtn = $("<button>")
.addClass(
"btn btn-xs btn-success")
.html("停止").appendTo(
div);
stopBtn.click(function() {
changeState(rowData, 0,
this, "确定停止吗",
"确认停止该任务么");
});
div.append("&nbsp;");
}
if (rowData.status == 0) {//已暂停,可以开启
var openBtn = $("<button>").addClass(
"btn btn-xs btn-success").html(
"开启").appendTo(div);
div.append("&nbsp;");
openBtn.click(function() {//开启变为待执行状态
changeState(rowData, 1, this,
"确定开启吗", "确定开启改任务么");
});
if (rowData.status == 1) {//执行中只可以查看
var editBtn = $("<button>")
.addClass(
"btn btn-xs btn-success")
.html("查看").appendTo(
div);
editBtn
.click(function() {
paramObj.markingPushFlag = '-1';
paramObj.markingPustId = rowData.id;
$("#body")
.load(
"/html/marketing/marketingPush/editMarkingPush.html");
});
} else {//非执行中状态可以进行其他部分操作
var editBtn = $("<button>")
.addClass(
"btn btn-xs btn-success")
.html("编辑").appendTo(
div);
editBtn.click(function() {
editJob(rowData);
//paramObj.markingPushFlag = '-1';
//paramObj.markingPustId = rowData.id;
//$("#body").load("/jobs/html/editMarkingPush.html");
});
div.append("&nbsp;");
var editBtn = $("<button>").addClass(
"btn btn-xs btn-success").html(
"编辑").appendTo(div);
editBtn.click(function() {
editJob(rowData);
});
div.append("&nbsp;");
div.append("&nbsp;");
div.append("&nbsp;");
}
if (rowData.status == 1) {//执行状态,可以停止
var stopBtn = $("<button>").addClass(
"btn btn-xs btn-success").html(
"停止").appendTo(div);
stopBtn.click(function() {
changeState(rowData, 0, this,
"确定停止吗", "确认停止该任务么");
});
div.append("&nbsp;");
}
}
var editBtn = $("<button>").addClass(
"btn btn-xs btn-success")
.html("查看").appendTo(div);
editBtn.click(function() {
return div;
}
} ]
});
showDetailJob(rowData);
});
return div;
}
} ]
});
//加载创建
$("#jobInfoDiv #jobCreateJobDiv").panel({
... ... @@ -240,104 +210,111 @@
}
}
}
function showCreatePage(){
function showCreatePage() {
$("#jobCreateJobDiv").show();
}
function editJob(job){
function editJob(job) {
var dialog = $("<div>").appendTo($("body"));
dialog.dialog({
title : "创建任务",
backdrop : "static",
content : buildCnt(job)
});
function buildCnt(job){
var cnt="<form class=\"form col-md-12 center-block\" name=\"form\" id=\"editjobinfo\">";
cnt+="<div class=\"form-group\">";
cnt=cnt+"任务名称:<input type=\"text\" class=\"form-control input-lg\" id=\"editjobName\" name=\"editjobName\" placeholder=\"任务名称\" value=";
function buildCnt(job) {
var cnt = "<form class=\"form col-md-12 center-block\" name=\"form\" id=\"editjobinfo\">";
cnt += "<div class=\"form-group\">";
cnt = cnt
+ "任务名称:<input type=\"text\" class=\"form-control input-lg\" id=\"editjobName\" name=\"editjobName\" placeholder=\"任务名称\" value=";
cnt =cnt+job.jobName;
cnt += " disabled=\"true\">";
cnt +="</div>";
cnt+="<div class=\"form-group\">";
cnt=cnt+"任务分组:<input type=\"text\" class=\"form-control input-lg\" id=\"editjobGroup\" name=\"editjobGroup\" placeholder=\"分组名称\" value=";
cnt += "</div>";
cnt += "<div class=\"form-group\">";
cnt = cnt
+ "任务分组:<input type=\"text\" class=\"form-control input-lg\" id=\"editjobGroup\" name=\"editjobGroup\" placeholder=\"分组名称\" value=";
cnt =cnt+job.jobGroup;
cnt += " disabled=\"true\">";
cnt +="</div>";
cnt+="<div class=\"form-group\">";
cnt=cnt+"所属模块:<input type=\"text\" class=\"form-control input-lg\" id=\"editmodule\" name=\"editmodule\" placeholder=\"所属模块\" value=";
cnt += "</div>";
cnt += "<div class=\"form-group\">";
cnt = cnt
+ "所属模块:<input type=\"text\" class=\"form-control input-lg\" id=\"editmodule\" name=\"editmodule\" placeholder=\"所属模块\" value=";
cnt =cnt+job.module;
cnt += " disabled=\"true\">";
cnt +="</div>";
cnt+="<div class=\"form-group\">";
cnt=cnt+"任务执行器:<input type=\"text\" class=\"form-control input-lg\" id=\"editprocessor\" name=\"editprocessor\" placeholder=\"任务执行器\" value=";
cnt += "</div>";
cnt += "<div class=\"form-group\">";
cnt = cnt
+ "任务执行器:<input type=\"text\" class=\"form-control input-lg\" id=\"editprocessor\" name=\"editprocessor\" placeholder=\"任务执行器\" value=";
cnt =cnt+job.processor;
cnt += ">";
cnt +="</div>";
cnt+="<div class=\"form-group\">";
cnt=cnt+"任务执行IP:<input type=\"text\" class=\"form-control input-lg\" id=\"editprocessip\" name=\"editprocessip\" placeholder=\"任务执行IP\" value=";
cnt += "</div>";
cnt += "<div class=\"form-group\">";
cnt = cnt
+ "任务执行IP:<input type=\"text\" class=\"form-control input-lg\" id=\"editprocessip\" name=\"editprocessip\" placeholder=\"任务执行IP\" value=";
cnt =cnt+job.processIp;
cnt += ">";
cnt +="</div>";
cnt+="<div class=\"form-group\">";
cnt=cnt+"任务类型:<select name=\"editjobtype\" id=\"editjobtype\">";
var tmp="<option value=\"0\" selected = \"selected\">单节点执行</option>";
var tmpsec="<option value=\"1\" >多节点执行</option>";
if(job.jobType == 1){
tmp="<option value=\"0\" >单节点执行</option>";
tmpsec="<option value=\"1\" selected = \"selected\">多节点执行</option>";
cnt += "</div>";
cnt += "<div class=\"form-group\">";
cnt = cnt + "任务类型:<select name=\"editjobtype\" id=\"editjobtype\">";
var tmp = "<option value=\"0\" selected = \"selected\">单节点执行</option>";
var tmpsec = "<option value=\"1\" >多节点执行</option>";
if (job.jobType == 1) {
tmp = "<option value=\"0\" >单节点执行</option>";
tmpsec = "<option value=\"1\" selected = \"selected\">多节点执行</option>";
}
cnt=cnt+tmp;
cnt=cnt+tmpsec;
cnt = cnt + tmp;
cnt = cnt + tmpsec;
cnt += "</select>";
cnt +="</div>";
cnt+="<div class=\"form-group\">";
cnt=cnt+"执行周期:<input type=\"text\" class=\"form-control input-lg\" id=\"editcronexception\" name=\"editcronexception\" placeholder=\"任务执行周期\" value=\"";
cnt += "</div>";
cnt += "<div class=\"form-group\">";
cnt = cnt
+ "执行周期:<input type=\"text\" class=\"form-control input-lg\" id=\"editcronexception\" name=\"editcronexception\" placeholder=\"任务执行周期\" value=\"";
cnt =cnt+job.cronExpression;
cnt += "\">";
cnt +="</div>";
cnt+="<div class=\"form-group\">";
cnt=cnt+"任务入参:<input type=\"text\" class=\"form-control input-lg\" id=\"editcontext\" name=\"editcontext\" placeholder=\"任务入参\" value=";
if(typeof(job.context) == "undefined"){
cnt=cnt+"";
}else{
cnt =cnt+job.context;
cnt += "</div>";
cnt += "<div class=\"form-group\">";
cnt = cnt
+ "任务入参:<input type=\"text\" class=\"form-control input-lg\" id=\"editcontext\" name=\"editcontext\" placeholder=\"任务入参\" value=";
if (typeof (job.context) == "undefined") {
cnt = cnt + "";
} else {
cnt = cnt + job.context;
}
cnt += ">";
cnt +="</div>";
cnt+="<div class=\"form-group\">";
cnt=cnt+"任务触发类型:<select name=\"editactivemode\" id=\"editactivemode\">";
var tmp="<option value=\"0\" selected = \"selected\">单次任务</option>";
var tmpsec="<option value=\"1\" >周期任务</option>";
if(job.activeMode == 1){
tmp="<option value=\"0\" >单次任务</option>";
tmpsec="<option value=\"1\" selected = \"selected\">周期任务</option>";
cnt += "</div>";
cnt += "<div class=\"form-group\">";
cnt = cnt
+ "任务触发类型:<select name=\"editactivemode\" id=\"editactivemode\">";
var tmp = "<option value=\"0\" selected = \"selected\">单次任务</option>";
var tmpsec = "<option value=\"1\" >周期任务</option>";
if (job.activeMode == 1) {
tmp = "<option value=\"0\" >单次任务</option>";
tmpsec = "<option value=\"1\" selected = \"selected\">周期任务</option>";
}
cnt=cnt+tmp;
cnt=cnt+tmpsec;
cnt = cnt + tmp;
cnt = cnt + tmpsec;
cnt += "</select>";
cnt +="</div>";
cnt+="<div class=\"form-group\">";
cnt+="<input type=\"button\" value=\"更新\" id=\"editJobBtn\" class=\"btn btn-primary btn-lg btn-block\" name=\"editJobBtn\" onclick=\"updatejob()\" />";
cnt+="</div>";
cnt +="</form>";
cnt += "</div>";
cnt += "<div class=\"form-group\">";
cnt += "<input type=\"button\" value=\"更新\" id=\"editJobBtn\" class=\"btn btn-primary btn-lg btn-block\" name=\"editJobBtn\" onclick=\"updatejob()\" />";
cnt += "</div>";
cnt += "</form>";
return cnt;
}
}
function updatejob(){
function updatejob() {
var jobName = $("#editjobName");
var jobGroup = $("#editjobGroup");
var module = $("#editmodule");
... ... @@ -348,16 +325,16 @@
var context = $("#editcontext");
var activemode = $("#editactivemode");
var jobinfo = {
"activeMode": activemode.val(),
"cronExpression": cronexception.val(),
"jobGroup": jobGroup.val(),
"jobName": jobName.val(),
"jobType": jobtype.val(),
"module": module.val(),
"processIp": processip.val(),
"processor": processor.val(),
"context": context.val()
};
"activeMode" : activemode.val(),
"cronExpression" : cronexception.val(),
"jobGroup" : jobGroup.val(),
"jobName" : jobName.val(),
"jobType" : jobtype.val(),
"module" : module.val(),
"processIp" : processip.val(),
"processor" : processor.val(),
"context" : context.val()
};
$.ajax({
url : "/jobs/jobmanager/updatejob.do",
contentType : "application/json; charset=utf-8",
... ... @@ -385,7 +362,10 @@
}
});
}
function showDetailJob(job) {
window.open("/jobs/html/showdetailjob.html?jobname=" + job.jobName
+ "&module=" + job.module);
}
</script>
... ...
... ... @@ -257,12 +257,13 @@
}
$.ajax($.extend({}, {
url : opt.url,
data : $.extend({}, lastQueryParam, {
data : JSON.stringify($.extend({}, lastQueryParam, {
pageSize : (opt.pagination === true ? opt.pageSize : 0),
currentPage : (opt.pagination === true ? currentPage : 0)
}),
})),
type : opt.type,
dataType : opt.dataType,
contentType : opt.contentType,
success : function(json) {
if (!json) {
//隐藏正在加载
... ...
... ... @@ -9,15 +9,17 @@ import java.util.Map;
import javax.annotation.Resource;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.yoho.jobs.common.domain.ConstantEnum;
import com.yoho.jobs.common.domain.JobInfo;
import com.yoho.jobs.dal.IJobResultMapper;
import com.yoho.jobs.dal.domain.ProcessResultVO;
import com.yoho.jobs.server.domain.JobResponse;
import com.yoho.jobs.server.domain.PageResponse;
import com.yoho.jobs.server.domain.ShowAllJobResponse;
import com.yoho.jobs.server.scheduler.JobService;
/**
... ... @@ -28,7 +30,12 @@ import com.yoho.jobs.server.scheduler.JobService;
public class JobServiceController {
@Resource(name = "jobService")
private JobService jobService;
@Resource
private IJobResultMapper jobResultMapper;
@Value("${limitrecord}")
private int limit;
@RequestMapping("/jobmanager/createjob.do")
public JobResponse createJob(@RequestBody JobInfo jobInfo) {
JobResponse response = new JobResponse();
... ... @@ -110,6 +117,32 @@ public class JobServiceController {
return response;
}
@RequestMapping("/jobmanager/getdetailjob.do")
public JobResponse getDetailJob(@RequestBody JobInfo jobInfo) {
JobResponse response = new JobResponse();
try {
List<ProcessResultVO> jobs = jobResultMapper.selectJobs(jobInfo.getJobName(), jobInfo.getModule(), limit);
PageResponse<ProcessResultVO> pr = new PageResponse<ProcessResultVO>();
pr.setRows(jobs);
pr.setCurrPage(1);
pr.setTotal(jobs.size());
response.setData(pr);
} catch (Exception e) {
buildJobResponse(ConstantEnum.JobResponse.FAIL, e.getMessage(), response);
}
return response;
}
public int getLimit() {
return limit;
}
public void setLimit(int limit) {
this.limit = limit;
}
private void buildJobResponse(String code, String message, JobResponse response) {
response.setCode(code);
... ...
... ... @@ -3,6 +3,8 @@
*/
package com.yoho.jobs.server.controller;
import java.util.Date;
import javax.annotation.Resource;
import org.springframework.stereotype.Controller;
... ... @@ -24,7 +26,7 @@ public class SaveJobInfoController {
@Resource
private IJobResultMapper jobResultMapper;
@RequestMapping("/saveJobResult")
@RequestMapping("/saveJobResult.do")
public void saveJobResult(@RequestBody ProcessResult jobInfo) {
ProcessResultVO result = new ProcessResultVO();
convert(result, jobInfo);
... ... @@ -48,5 +50,6 @@ public class SaveJobInfoController {
result.setProcessIp(jobInfo.getJobInfo().getProcessIp());
result.setProcessor(jobInfo.getJobInfo().getProcessor());
result.setStatus(jobInfo.getJobInfo().getStatus());
result.setRecordDate(new Date());
}
}
... ...
package org.yoho.jobs.server;
//import org.junit.Test;
import java.util.Date;
import org.junit.Test;
/**
* Unit test for simple App.
*/
public class AppTest {
// @Test
@Test
public void test() {
String path = "/job/jobclient/order/jobinfo/testjobname";
String prefix = "/job/jobclient/";
String s =path.substring(prefix.length());
String a = s.substring(0, s.indexOf("/"));
System.out.println(a);
Date date = new Date();
System.out.println(date.toString());
}
}
... ...
web.context=jobs
zkAddress=172.16.6.85:2181
web.port=8080
limitrecord=5
... ...