Commit 0f3e8b43 authored by mcb's avatar mcb

数据运维修改

parent 5e17a283
...@@ -776,5 +776,23 @@ public class AzkabanApiUtils2 { ...@@ -776,5 +776,23 @@ public class AzkabanApiUtils2 {
String result = HttpClientUtils.getJsonForParam(executeFlowUrl,new HashMap<>()); String result = HttpClientUtils.getJsonForParam(executeFlowUrl,new HashMap<>());
return result; return result;
} }
/**
* 获取 业务流程 执行实例日志
* @author Bellamy
* @since 2021-03-08
* @return
*/
public String getInstanceLog(String execId) {
String sessionId = login();
String executeFlowUrl = azkabanServerUrl + "/executor?ajax=fetchExecFlowLogs&";
Map params = new HashMap();
params.put("session.id",sessionId);
params.put("execid",execId);
params.put("offset",0);
params.put("length",50000);
String result = HttpClientUtils.getJsonForParam(executeFlowUrl,params);
return result;
}
} }
package com.jz.dmp.azkaban.dao; package com.jz.dmp.azkaban.dao;
import com.jz.dmp.azkaban.entity.ProjectFlows;
import com.jz.dmp.modules.controller.azkaban.bean.ProjectFlowsDto;
import com.jz.dmp.modules.controller.bean.IndexProjAzkabanStatuDto;
import com.jz.dmp.modules.controller.dataOperation.bean.DataDevExamplesListDto; import com.jz.dmp.modules.controller.dataOperation.bean.DataDevExamplesListDto;
import com.jz.dmp.modules.controller.dataOperation.bean.DataDevExamplesListReq;
import com.jz.dmp.modules.controller.dataOperation.bean.DataDevTaskListReq;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
import java.util.List; import java.util.List;
...@@ -29,15 +24,6 @@ public interface ExecutionFlowsMapper { ...@@ -29,15 +24,6 @@ public interface ExecutionFlowsMapper {
*/ */
List<DataDevExamplesListDto> queryDevExamplesListPage(Map saveParams) throws Exception; List<DataDevExamplesListDto> queryDevExamplesListPage(Map saveParams) throws Exception;
/**
* 获取执行实例的日志详情
*
* @return
* @author Bellamy
* @since 2021-02-03
*/
List<Map> queryExamplesLogByExecId(String execId) throws Exception;
Map<String, Object> queryTaskInstanceStatus(@Param("taskName") String [] taskName) throws Exception; Map<String, Object> queryTaskInstanceStatus(@Param("taskName") String [] taskName) throws Exception;
/** /**
......
...@@ -7,6 +7,7 @@ import com.jz.dmp.modules.controller.dataOperation.bean.*; ...@@ -7,6 +7,7 @@ import com.jz.dmp.modules.controller.dataOperation.bean.*;
import com.jz.dmp.modules.service.DmpDevelopTaskService; import com.jz.dmp.modules.service.DmpDevelopTaskService;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam; import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
...@@ -64,14 +65,18 @@ public class DmpDevExamplesController { ...@@ -64,14 +65,18 @@ public class DmpDevExamplesController {
*/ */
@ApiOperation(value = "执行实例日志详情", notes = "执行实例日志详情") @ApiOperation(value = "执行实例日志详情", notes = "执行实例日志详情")
@GetMapping(value = "/log") @GetMapping(value = "/log")
@ApiImplicitParam(name = "execId", value = "执行实例ID", required = true) @ApiImplicitParams({@ApiImplicitParam(name = "execId", value = "执行实例ID", required = true),
public JsonResult getExamplesLog(@RequestParam String execId) { @ApiImplicitParam(name = "projectId", value = "projectId", required = true)})
public JsonResult getExamplesLog(@RequestParam String execId,@RequestParam String projectId) {
if (StringUtils.isEmpty(execId)) { if (StringUtils.isEmpty(execId)) {
return JsonResult.error(ResultCode.PARAMS_ERROR, "执行实例ID不能为空!"); return JsonResult.error(ResultCode.PARAMS_ERROR, "执行实例ID不能为空!");
} }
if (StringUtils.isEmpty(projectId)) {
return JsonResult.error(ResultCode.PARAMS_ERROR, "projectId不能为空!");
}
JsonResult result = new JsonResult(); JsonResult result = new JsonResult();
try { try {
result = dmpDevelopTaskService.queryExamplesLogByExecId(execId); result = dmpDevelopTaskService.queryExamplesLogByExecId(execId,projectId);
} catch (Exception e) { } catch (Exception e) {
result.setCode(ResultCode.INTERNAL_SERVER_ERROR); result.setCode(ResultCode.INTERNAL_SERVER_ERROR);
result.setMessage("查询失败!"); result.setMessage("查询失败!");
......
...@@ -178,7 +178,7 @@ public interface DmpDevelopTaskService { ...@@ -178,7 +178,7 @@ public interface DmpDevelopTaskService {
* @author Bellamy * @author Bellamy
* @since 2021-02-03 * @since 2021-02-03
*/ */
JsonResult queryExamplesLogByExecId(String execId) throws Exception; JsonResult queryExamplesLogByExecId(String execId, String projectId) throws Exception;
/** /**
* 运维大屏--获取任务状态 * 运维大屏--获取任务状态
......
...@@ -1664,19 +1664,17 @@ public class DmpDevelopTaskServiceImpl extends BaseService implements DmpDevelop ...@@ -1664,19 +1664,17 @@ public class DmpDevelopTaskServiceImpl extends BaseService implements DmpDevelop
* @since 2021-02-03 * @since 2021-02-03
*/ */
@Override @Override
public JsonResult queryExamplesLogByExecId(String execId) throws Exception { public JsonResult queryExamplesLogByExecId(String execId, String projectId) throws Exception {
List<Map> list = executionFlowsMapper.queryExamplesLogByExecId(execId); DmpProjectSystemInfo publishToProjectSystemInfo = dmpProjectDao.queryProjectSystemInfo(Long.valueOf(projectId));
if (list.size() > 0 && list != null) {
list.forEach(map -> {
try {
map.put("log", new String(String.valueOf(map.get("log")).getBytes("ISO-8859-1"), "UTF-8"));
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
}); //调用azkaban服务
String azkabanApiUrl = publishToProjectSystemInfo.getAzkabanMonitorUrl();
AzkabanApiUtils2 azkabanApiUtils = new AzkabanApiUtils2(azkabanApiUrl, redisTemplate);
Map result = (Map) JSONObject.parse(azkabanApiUtils.getInstanceLog(execId));
if (result.containsKey("data")) {
return JsonResult.ok(result);
} }
return JsonResult.ok(list); return JsonResult.error(ResultCode.OPERATION_DATA_NO_EXIST,String.valueOf(result.get("error")));
} }
/** /**
......
...@@ -190,23 +190,6 @@ ...@@ -190,23 +190,6 @@
<if test="endTime != null and endTime != ''">and #{endTime} >= from_unixtime(submit_time/1000,'%Y-%m-%d %H:%i:%s')</if> <if test="endTime != null and endTime != ''">and #{endTime} >= from_unixtime(submit_time/1000,'%Y-%m-%d %H:%i:%s')</if>
</select> </select>
<!-- <resultMap type="java.util.HashMap" id="taskExamplesLog">
<result property="execId" column="exec_id" jdbcType="INTEGER"/>
<result property="name" column="name" jdbcType="VARCHAR"/>
<result property="log" column="log" jdbcType="BLOB" typeHandler="com.jz.common.persistence.CBTHandler"/>
<result property="uploadTime" column="upload_time" jdbcType="INTEGER"/>
</resultMap>-->
<!--获取执行实例的日志详情-->
<select id="queryExamplesLogByExecId" parameterType="string" resultType="java.util.Map">
select
exec_id as execId,
name,
log,
from_unixtime(upload_time/1000, '%Y-%m-%d %H:%i:%s') as uploadTime
from execution_logs
where 1=1 and exec_id=#{execId}
</select>
<!--统计实例状态数--> <!--统计实例状态数-->
<select id="queryTaskInstanceStatus" resultType="java.util.Map"> <select id="queryTaskInstanceStatus" resultType="java.util.Map">
select select
...@@ -227,13 +210,14 @@ ...@@ -227,13 +210,14 @@
<!--查询业务流程任务,最后一个执行实例的状态--> <!--查询业务流程任务,最后一个执行实例的状态-->
<select id="queryLastStatus" resultType="java.util.Map"> <select id="queryLastStatus" resultType="java.util.Map">
SELECT SELECT
exec_id AS execId, t.exec_id AS execId,
project_id as projectId, t.project_id as projectId,
flow_id AS taskName, t.flow_id AS taskName,
max(from_unixtime( submit_time / 1000, '%Y-%m-%d %H:%i:%s' )) AS startTime, max(from_unixtime( t.submit_time / 1000, '%Y-%m-%d %H:%i:%s' )) AS startTime,
(case when status='30' then '运行中' when status='50' then '成功' when status='70' then '失败' end) status (case when t.status='30' then '运行中' when t.status='50' then '成功' when t.status='70' then '失败' end) status
FROM FROM
execution_flows execution_flows t
inner join projects t1 on t.project_id=t1.id and active=1
WHERE 1 = 1 WHERE 1 = 1
<if test="status != null and status !='' ">and status=#{status}</if> <if test="status != null and status !='' ">and status=#{status}</if>
<if test="taskName != null and taskName !='' "> <if test="taskName != null and taskName !='' ">
......
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