...
|
...
|
@@ -4,6 +4,8 @@ |
|
|
package com.yoho.jobs.server.controller;
|
|
|
|
|
|
import java.util.Date;
|
|
|
import java.util.HashMap;
|
|
|
import java.util.Map;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
|
...
|
...
|
@@ -11,9 +13,11 @@ import org.springframework.stereotype.Controller; |
|
|
import org.springframework.web.bind.annotation.RequestBody;
|
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
|
|
|
import com.yoho.jobs.common.domain.ConstantEnum;
|
|
|
import com.yoho.jobs.common.domain.ProcessResult;
|
|
|
import com.yoho.jobs.dal.IJobResultMapper;
|
|
|
import com.yoho.jobs.dal.domain.ProcessResultVO;
|
|
|
import com.yoho.jobs.server.alarm.SendAlarmTool;
|
|
|
|
|
|
/**
|
|
|
* @author yanzhang.fu
|
...
|
...
|
@@ -26,12 +30,22 @@ public class SaveJobInfoController { |
|
|
@Resource
|
|
|
private IJobResultMapper jobResultMapper;
|
|
|
|
|
|
@Resource(name = "sendAlarmTool")
|
|
|
private SendAlarmTool sendAlarmTool;
|
|
|
|
|
|
@RequestMapping("/saveJobResult.do")
|
|
|
public void saveJobResult(@RequestBody ProcessResult jobInfo) {
|
|
|
ProcessResultVO result = new ProcessResultVO();
|
|
|
convert(result, jobInfo);
|
|
|
//TODO 若执行失败,则上报告警并入库
|
|
|
|
|
|
// TODO 若执行失败,则上报告警并入库
|
|
|
if (ConstantEnum.JobProcessResultCode.ERROR_CODE.equals(jobInfo.getCode())) {
|
|
|
// 上报告警
|
|
|
Map<String, String> tags = new HashMap<String, String>();
|
|
|
buildTags(result, tags);
|
|
|
Map<String, Object> fields = new HashMap<String, Object>();
|
|
|
buildFields(result, fields);
|
|
|
sendAlarmTool.sendAlarm(tags, fields);
|
|
|
}
|
|
|
jobResultMapper.insertJob(result);
|
|
|
}
|
|
|
|
...
|
...
|
@@ -54,4 +68,15 @@ public class SaveJobInfoController { |
|
|
result.setStatus(jobInfo.getJobInfo().getStatus());
|
|
|
result.setRecordDate(new Date());
|
|
|
}
|
|
|
|
|
|
private void buildTags(ProcessResultVO result, Map<String, String> tags) {
|
|
|
tags.put("jobname", result.getJobName());
|
|
|
tags.put("module", result.getModule());
|
|
|
}
|
|
|
|
|
|
private void buildFields(ProcessResultVO result, Map<String, Object> fields) {
|
|
|
fields.put("message", result.getMessage());
|
|
|
fields.put("desc", "exec job faild");
|
|
|
|
|
|
}
|
|
|
} |
...
|
...
|
|