Commit a9073cad authored by sml's avatar sml

Merge branch 'dmp_dev' of http://gitlab.ioubuy.cn/yaobenzhang/jz-dmp-service.git into dmp_dev

parents 4f645937 4726f8d6
......@@ -62,4 +62,8 @@ public class CommConstant {
//azkaban相关常量
public static final String AZKABAN_PROJECTNAME_PREFIX = "jz_workflow_new_"; //azkaban项目名称前缀
/***************************************************/
//模板名称
public static final String API_TEST = "api_test.ftl";
public static final String realTimeTask = "source_connector.ftl";
}
......@@ -74,13 +74,18 @@ public class GatewayApiConstant {
public static final String listServerApplyApi = "/api/interface/listServerApplyApi";
//获取文件夹树
public static final String folderTree = "/api/producer/getFileCatalog";
//服务开发---获取ApiId
public static final String getApiId = "/api/producer/getCustomApiId";
//创建项目文件夹
public static final String createProjectFolder = "/api/producer/createProjectFolder";
//授权--组织名称查询
public static final String getOrgNameList = "/api/auth/get-org-list";
//API测试--下拉框
public static final String listGetApiKey = "/api/interface/listGetApiKey";
//删除文件夹
public static final String delFolder = "/api/producer/delProjectFolder";
//删除文件夹
public static final String functionTemplate = "/api/producer/getFunctionTemplateList";
private static Logger logger = LoggerFactory.getLogger(GatewayApiConstant.class);
......@@ -93,7 +98,7 @@ public class GatewayApiConstant {
if (StringUtils.isEmpty(resultData)) {
throw new RuntimeException("failed!");
}
logger.info("#################响应结果数据{}" + resultData);
logger.info("############## response results{}" + resultData);
Map jsonObject = JSONObject.parseObject(resultData);
if (jsonObject.containsKey("code")) {
......@@ -121,7 +126,7 @@ public class GatewayApiConstant {
if (StringUtils.isEmpty(returnData)) {
throw new RuntimeException("failed!");
}
logger.info("#################响应结果{}" + returnData);
logger.info("############## response results{}" + returnData);
Map jsonObject = JSONObject.parseObject(returnData);
if (jsonObject.containsKey("code")) {
if ("200".equals(jsonObject.get("code").toString())) {
......@@ -149,7 +154,7 @@ public class GatewayApiConstant {
if (StringUtils.isEmpty(returnData)) {
throw new RuntimeException("failed!");
}
logger.info("#################响应结果{}" + returnData);
logger.info("############## response results{}" + returnData);
Map jsonObject = JSONObject.parseObject(returnData);
if (jsonObject.containsKey("code")) {
if ("200".equals(jsonObject.get("code").toString())) {
......
package com.jz.common.utils;
import freemarker.core.ParseException;
import freemarker.template.MalformedTemplateNameException;
import freemarker.template.Template;
import freemarker.template.TemplateException;
import freemarker.template.TemplateNotFoundException;
import org.springframework.web.servlet.view.freemarker.FreeMarkerConfig;
import java.io.IOException;
import java.io.StringWriter;
import java.util.Map;
/**
* @ClassName: FreeMarkerUtils
* @Description: freeMarkerUtils
* @Author Bellamy
* @Date 2021/3/3
* @Version 1.0
*/
public class FreeMarkerUtils {
/**
* 使用freemaker模板生成 kafka connector 请求参数
*
* @param type 模板类型
* @param dataModel 模板里定义的变量数据对象
* @return
* @author Bellamy
*/
public static String freemakerJson(String type, Map<String, String> dataModel, FreeMarkerConfig freeMarkerConfig) {
StringWriter stringWriter = new StringWriter();
try {
Template template = freeMarkerConfig.getConfiguration().getTemplate(type);
if (template != null) {
try {
template.process(dataModel, stringWriter);
} catch (TemplateException e) {
e.printStackTrace();
}
}
} catch (TemplateNotFoundException e) {
e.printStackTrace();
} catch (MalformedTemplateNameException e) {
e.printStackTrace();
} catch (ParseException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
return stringWriter.toString();
}
}
package com.jz.common.utils;
import com.jz.dmp.modules.controller.dataService.DmpApiMangeController;
import org.apache.commons.codec.digest.DigestUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.UnsupportedEncodingException;
import java.security.MessageDigest;
/**
*
......@@ -16,7 +20,10 @@ import java.io.UnsupportedEncodingException;
*/
public class MD5SignUtils {
private static Logger logger = LoggerFactory.getLogger(MD5SignUtils.class);
private static final String DEFAULT_CHARSET = "UTF-8";
private static final String SIGN_TYPE = "MD5";
/**
* 签名
......@@ -74,4 +81,37 @@ public class MD5SignUtils {
throw new RuntimeException("MD5签名过程中出现错误,指定的编码集不对,您目前指定的编码集是:" + charset);
}
}
/**
* MD5加盐加密
*
* @param str
* @param salt
* @return
*/
public static String encrypt(String str, String salt) {
try {
MessageDigest md5 = MessageDigest.getInstance(SIGN_TYPE);
md5.update((str + salt).getBytes(DEFAULT_CHARSET));
return byte2hex(md5.digest());
} catch (Exception e) {
if (logger.isDebugEnabled()) {
logger.debug("md5 加密异常", e);
}
}
return "";
}
public static String byte2hex(byte[] bytes) {
StringBuilder sign = new StringBuilder();
for (int i = 0; i < bytes.length; i++) {
String hex = Integer.toHexString(bytes[i] & 0xFF);
if (hex.length() == 1) {
sign.append("0");
}
sign.append(hex.toUpperCase());
}
return sign.toString();
}
}
package com.jz.common.utils;
import com.alibaba.fastjson.JSON;
import org.apache.commons.lang3.StringUtils;
import java.io.UnsupportedEncodingException;
import java.lang.reflect.Field;
import java.net.URLEncoder;
import java.util.*;
/**
* @author ZC
* @PACKAGE_NAME: com.jz.dm.common.util
* @PROJECT_NAME: jz-dm-parent
* @NAME: MapUtil
* @DATE: 2021-1-2/14:02
* @DAY_NAME_SHORT: 周六
* @Description:
**/
public class MapUtil {
/**
* 获取签名参数
*
* @param apiKey
* @param method
* @param signType
* @return
*/
//public static String getSignValue(String apiKey, String method, String signType) {
// StringBuilder builder = new StringBuilder();
// builder.append("apiKey=").append(apiKey).append(LoggingConstants.AND_SPILT)
// .append("method=").append(method).append(LoggingConstants.AND_SPILT)
// .append("signType=").append(signType);
// return builder.toString();
//}
/**
* 将对象转成TreeMap,属性名为key,属性值为value
*
* @param object 对象
* @return
* @throws IllegalAccessException
*/
public static TreeMap<String, String> objToMap(Object object) throws IllegalAccessException {
Class clazz = object.getClass();
TreeMap<String, String> treeMap = new TreeMap<String, String>();
while (null != clazz.getSuperclass()) {
Field[] declaredFields1 = clazz.getDeclaredFields();
for (Field field : declaredFields1) {
String name = field.getName();
// 获取原来的访问控制权限
boolean accessFlag = field.isAccessible();
// 修改访问控制权限
field.setAccessible(true);
Object value = field.get(object);
// 恢复访问控制权限
field.setAccessible(accessFlag);
if (null != value && StringUtils.isNotBlank(value.toString())) {
//如果是List,将List转换为json字符串
if (value instanceof List) {
value = JSON.toJSONString(value);
}
treeMap.put(name, String.valueOf(value));
}
}
clazz = clazz.getSuperclass();
}
return treeMap;
}
/**
* 按照指定的分割符将list转换为String
*
* @param list
* @param separator
* @return
*/
public static String listToString(List list, String separator) {
StringBuilder sb = new StringBuilder();
for (int i = 0; i < list.size(); i++) {
if (i == list.size() - 1) {
sb.append(list.get(i));
} else {
sb.append(list.get(i));
sb.append(separator);
}
}
return sb.toString();
}
/**
* * 把数组元素按照按照字典倒序排序,并按照“参数=参数值”的模式用“&”字符拼接成字符串
* @param params 需要排序并参与字符拼接的参数组
* @return 拼接后字符串
*/
public static String stringInvertSort(Map<String, String> params) {
List<String> keys = new ArrayList<String>(params.keySet());
Collections.reverse(keys);
String prestr = "";
for (int i = 0; i < keys.size(); i++) {
String key = keys.get(i);
String value = params.get(key);
try {
value = URLEncoder.encode(value, "UTF-8");
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
if (i == keys.size() - 1) {//拼接时,不包括最后一个&字符
prestr = prestr + key + "=" + value;
} else {
prestr = prestr + key + "=" + value + "&";
}
}
return prestr;
}
/**
*   * 把数组所有元素字典排序,并按照“参数=参数值”的模式用“&”字符拼接成字符串
*   * @param params 需要排序并参与字符拼接的参数组
*   * @return 拼接后字符串 
*/
public static String stringNormalSort(Map<String, String> params) {
List<String> keys = new ArrayList<String>(params.keySet());
Collections.sort(keys);
String prestr = "";
for (int i = 0; i < keys.size(); i++) {
String key = keys.get(i);
String value = params.get(key);
try {
value = URLEncoder.encode(value, "UTF-8");
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
if (i == keys.size() - 1) {//拼接时,不包括最后一个&字符
prestr = prestr + key + "=" + value;
} else {
prestr = prestr + key + "=" + value + "&";
}
}
return prestr;
}
class SpellComparatorUtils implements Comparator {
@Override
public int compare(Object o1, Object o2) {
try {
// 取得比较对象的汉字编码,并将其转换成字符串
String s1 = new String(o1.toString().getBytes("GB2312"), "ISO-8859-1");
String s2 = new String(o2.toString().getBytes("GB2312"), "ISO-8859-1");
// 运用String类的 compareTo()方法对两对象进行比较
return s1.compareTo(s2);
} catch (Exception e) {
e.printStackTrace();
}
return 0;
}
}
public static void main(String[] args) {
//Map<String, String> map = new HashMap();
//map.put("name", "hello");
//map.put("value", "world");
//System.out.println(createLinkStringByGet(map));
StringJoiner joiner = new StringJoiner(",","[","]");
joiner.add("123");
joiner.add("456");
joiner.add("789");
System.out.println(joiner);
}
}
......@@ -159,7 +159,7 @@ public class HttpClientUtils {
try {
httpClient = HttpClients.createDefault();
httpPost = new HttpPost(url);
RequestConfig requestConfig = RequestConfig.custom().setSocketTimeout(50000).setConnectTimeout(50000).build();//设置请求和传输超时时间
RequestConfig requestConfig = RequestConfig.custom().setSocketTimeout(5000).setConnectTimeout(5000).build();//设置请求和传输超时时间
httpPost.setConfig(requestConfig);
StringEntity se = new StringEntity(json, "UTF-8");
//StringEntity se = new StringEntity("UTF-8");
......@@ -199,7 +199,7 @@ public class HttpClientUtils {
try {
httpClient = HttpClients.createDefault();
httpPost = new HttpPost(url);
RequestConfig requestConfig = RequestConfig.custom().setSocketTimeout(50000).setConnectTimeout(50000).build();//设置请求和传输超时时间
RequestConfig requestConfig = RequestConfig.custom().setSocketTimeout(10000).setConnectTimeout(10000).build();//设置请求和传输超时时间
httpPost.setConfig(requestConfig);
/* StringEntity se = new StringEntity(json, "UTF-8");
se.setContentType("application/x-www-form-urlencoded");
......@@ -495,7 +495,7 @@ public class HttpClientUtils {
try {
httpClient = HttpClients.createDefault();
httpPost = new HttpPost(url);
RequestConfig requestConfig = RequestConfig.custom().setSocketTimeout(50000).setConnectTimeout(50000).build();//设置请求和传输超时时间
RequestConfig requestConfig = RequestConfig.custom().setSocketTimeout(5000).setConnectTimeout(5000).build();//设置请求和传输超时时间
httpPost.setConfig(requestConfig);
httpPost.setHeader("token", token);
StringEntity se = new StringEntity(json, "UTF-8");
......@@ -562,6 +562,8 @@ public class HttpClientUtils {
try {
// 创建httpget.
HttpGet httpget = new HttpGet(requestUrl);
RequestConfig requestConfig = RequestConfig.custom().setSocketTimeout(5000).setConnectTimeout(5000).build();//设置请求和传输超时时间
httpget.setConfig(requestConfig);
System.out.println("get executing request " + httpget.getURI());
// 执行get请求.
CloseableHttpResponse response = httpclient.execute(httpget);
......@@ -572,7 +574,7 @@ public class HttpClientUtils {
System.out.println(response.getStatusLine());
if (entity != null) {
result = EntityUtils.toString(entity);
LOGGER.info(result);
LOGGER.info("response results{}" + result);
}
} catch (ClientProtocolException e) {
......
......@@ -37,4 +37,8 @@ public interface ExecutionFlowsMapper {
* @since 2021-02-03
*/
List<Map> queryExamplesLogByExecId(String execId) throws Exception;
Map<String, Object> queryTaskInstanceStatus() throws Exception;
List<Map> queryLastStatus(@Param("taskName") String[] taskName) throws Exception;
}
......@@ -218,6 +218,26 @@ public class OfflineSynchController {
return jsonResult;
}
/**
* sync-获取数据源表字段
*
* @return
* @author Bellamy
*/
@ApiOperation(value = "sync-获取数据源表字段", notes = "sync-获取数据源表字段")
@PostMapping(value = "/getSyncColumns")
public JsonResult getSyncSoureAndTargetColumns(@RequestBody @Validated Map<String, List<SynchTableColumnsReq>> req) throws Exception {
JsonResult jsonResult = new JsonResult();
try {
jsonResult = offlineSynchService.getSyncSoureAndTargetColumns(req);
} catch (Exception e) {
jsonResult.setMessage(e.getMessage());
jsonResult.setCode(ResultCode.INTERNAL_SERVER_ERROR);
e.printStackTrace();
}
return jsonResult;
}
/**
* 校验规则
*
......
......@@ -70,7 +70,7 @@ public class RealTimeSyncController {
}
/**
* 批量启动实时同步任务
* 批量启动/停止启动实时同步任务
*
* @return
* @author Bellamy
......
......@@ -28,6 +28,9 @@ public class SynchTableColumnsReq implements Serializable {
@ApiModelProperty(value = "目标表名称")
private String targetTableName;
@ApiModelProperty(value = "字段名称")
private String fieldName;
public Long getSourceDbId() {
return sourceDbId;
}
......@@ -44,4 +47,11 @@ public class SynchTableColumnsReq implements Serializable {
this.sourceDbId = sourceDbId;
}
public String getFieldName() {
return fieldName;
}
public void setFieldName(String fieldName) {
this.fieldName = fieldName;
}
}
......@@ -3,6 +3,7 @@ package com.jz.dmp.modules.controller.dataOperation;
import com.jz.common.constant.JsonResult;
import com.jz.common.constant.ResultCode;
import com.jz.common.page.PageInfoResponse;
import com.jz.dmp.modules.controller.DataIntegration.bean.ConflictCheckReq;
import com.jz.dmp.modules.controller.DataIntegration.bean.RealTimeSyncListDto;
import com.jz.dmp.modules.controller.DataIntegration.bean.RealTimeSyncListReq;
import com.jz.dmp.modules.controller.dataOperation.bean.DataDevTaskListDto;
......@@ -74,4 +75,28 @@ public class DmpDevTaskController {
JsonResult list = dmpDevelopTaskService.runTaskByTaskId(taskId);
return list;
}
/**
* 运维大屏--获取任务状态
*
* @return
* @author Bellamy
* @since 2021-02-22
*/
@ApiOperation(value = "运维大屏--重点关注任务状态", notes = "重点关注")
@PostMapping(value = "/getTaskStatus")
public JsonResult getTaskStatus(@RequestParam String projectId) throws Exception {
if (StringUtils.isEmpty(projectId)) {
return new JsonResult(ResultCode.PARAMS_ERROR, "projectId不能为空!");
}
JsonResult result = new JsonResult();
try {
result = dmpDevelopTaskService.getTaskStatus(projectId);
} catch (Exception e) {
result.setMessage(e.getMessage());
result.setCode(ResultCode.INTERNAL_SERVER_ERROR);
e.printStackTrace();
}
return result;
}
}
......@@ -44,6 +44,9 @@ public class DataDevTaskListReq extends BasePageBean {
@ApiModelProperty(value = "任务类型")
private String taskType;
@ApiModelProperty(value = "最后执行状态")
private String status;
public String getProjectId() {
return projectId;
}
......@@ -75,4 +78,12 @@ public class DataDevTaskListReq extends BasePageBean {
public void setTaskType(String taskType) {
this.taskType = taskType;
}
public String getStatus() {
return status;
}
public void setStatus(String status) {
this.status = status;
}
}
......@@ -37,7 +37,7 @@ public class DmpApiMangeController {
@Autowired
private DmpApiMangeService dmpApiMangeService;
/* *//**
/* *//**
* 授权给他人的API-列表分页查询
*
* @return
......@@ -82,7 +82,7 @@ public class DmpApiMangeController {
return jsonResult;
}
/* *//**
/* *//**
* 发布的API-API列表分页查询
*
* @author Bellamy
......@@ -151,7 +151,7 @@ public class DmpApiMangeController {
return jsonResult;
}
/* *//**
/* *//**
* 授权给组织-提交保存
*
* @author Bellamy
......@@ -178,11 +178,32 @@ public class DmpApiMangeController {
* @since 2021-01-19
*/
@ApiOperation(value = "API测试", notes = "API测试")
@GetMapping(value = "/apiTestInfo")
public JsonResult getApiTestInfo(@RequestBody Map<String,Object> params, HttpServletRequest httpRequest) {
@PostMapping(value = "/apiTestInfo")
public JsonResult getApiTestInfo(@RequestBody Map<String, String> apiKey, HttpServletRequest httpRequest) {
JsonResult jsonResult = new JsonResult();
try {
jsonResult = dmpApiMangeService.apiTestInfo(params);
jsonResult = dmpApiMangeService.apiTestInfo(apiKey);
} catch (Exception e) {
jsonResult.setMessage(e.getMessage());
jsonResult.setCode(ResultCode.INTERNAL_SERVER_ERROR);
e.printStackTrace();
}
return jsonResult;
}
/**
* API测试--下拉框
*
* @author Bellamy
* @since 2021-03-03
*/
@ApiOperation(value = "API测试--下拉框", notes = "API测试--下拉框")
@GetMapping(value = "/apiTestGetApiKey")
@ApiImplicitParam(name = "apiName", value = "apiName")
public JsonResult getApiTestGetApiKey(@RequestParam(required = false) String apiName, HttpServletRequest httpRequest) {
JsonResult jsonResult = new JsonResult();
try {
jsonResult = dmpApiMangeService.getApiTestGetApiKey(apiName);
} catch (Exception e) {
jsonResult.setMessage(e.getMessage());
jsonResult.setCode(ResultCode.INTERNAL_SERVER_ERROR);
......@@ -214,7 +235,7 @@ public class DmpApiMangeController {
return jsonResult;
}
/* *//**
/* *//**
* 授权模糊查询组织信息
*
* @author Bellamy
......@@ -370,4 +391,25 @@ public class DmpApiMangeController {
return jsonResult;
}
/**
* 授权--组织名称查询
*
* @author Bellamy
* @since 2021-03-02
*/
@ApiOperation(value = "授权--组织名称查询", notes = "授权--组织名称查询")
@GetMapping(value = "/getAuthOrgName")
@ApiImplicitParam(name = "orgName", value = "组织名称", required = true)
public JsonResult getAuthOrgName(@RequestParam String orgName) {
JsonResult jsonResult = new JsonResult();
try {
jsonResult = dmpApiMangeService.getAuthOrgName(orgName);
} catch (Exception e) {
jsonResult.setMessage(e.getMessage());
jsonResult.setCode(ResultCode.INTERNAL_SERVER_ERROR);
e.printStackTrace();
}
return jsonResult;
}
}
\ No newline at end of file
......@@ -298,11 +298,33 @@ public class DmpApiServiceMangeController {
@ApiOperation(value = "获取文件夹列表", notes = "获取文件夹列表")
@GetMapping(value = "/folderTree")
@ApiImplicitParams({@ApiImplicitParam(name = "projectId", value = "项目id"),
@ApiImplicitParam(name = "orgCode", value = "组织编码")})
public JsonResult getFolderTree(@RequestParam(name = "projectId", required = false) String projectId, @RequestParam(name = "orgCode", required = false) String orgCode) {
@ApiImplicitParam(name = "orgFolder", value = "组织编码")})
public JsonResult getFolderTree(@RequestParam(name = "projectId", required = false) String projectId, @RequestParam(name = "orgFolder", required = false) String orgFolder) {
JsonResult jsonResult = new JsonResult();
try {
jsonResult = dmpApiServiceMangeService.getFolderTree(projectId, orgCode);
jsonResult = dmpApiServiceMangeService.getFolderTree(projectId, orgFolder);
} catch (Exception e) {
jsonResult.setMessage(e.getMessage());
jsonResult.setCode(ResultCode.INTERNAL_SERVER_ERROR);
e.printStackTrace();
}
return jsonResult;
}
/**
* 删除文件夹
*
* @return
* @author Bellamy
* @since 2021-03-3
*/
@ApiOperation(value = "删除文件夹", notes = "删除文件夹")
@GetMapping(value = "/delFolder")
@ApiImplicitParam(name = "id", value = "文件夹id", required = true)
public JsonResult delFolderById(@RequestParam String id) throws Exception {
JsonResult jsonResult = new JsonResult();
try {
jsonResult = dmpApiServiceMangeService.delFolderById(id);
} catch (Exception e) {
jsonResult.setMessage(e.getMessage());
jsonResult.setCode(ResultCode.INTERNAL_SERVER_ERROR);
......@@ -332,12 +354,12 @@ public class DmpApiServiceMangeController {
}
/**
* 创建项目文件夹
* 创建/编辑项目文件夹
*
* @author Bellamy
* @since 2021-02-24
*/
@ApiOperation(value = "创建项目文件夹", notes = "创建项目文件夹")
@ApiOperation(value = "创建/编辑项目文件夹", notes = "创建/编辑项目文件夹")
@PostMapping(value = "/createProjectFolder")
public JsonResult createProjectFolder(@RequestBody @Validated CreateFolderReq req, HttpServletRequest httpRequest) {
JsonResult jsonResult = new JsonResult();
......@@ -351,6 +373,27 @@ public class DmpApiServiceMangeController {
return jsonResult;
}
/**
* 获取function模板列表
*
* @return
* @author Bellamy
* @since 2021-03-3
*/
@ApiOperation(value = "获取function模板列表", notes = "获取function模板列表")
@GetMapping(value = "/functionTemplate")
public JsonResult getFunctionTemplateList() throws Exception {
JsonResult jsonResult = new JsonResult();
try {
jsonResult = dmpApiServiceMangeService.getFunctionTemplateList();
} catch (Exception e) {
jsonResult.setMessage(e.getMessage());
jsonResult.setCode(ResultCode.INTERNAL_SERVER_ERROR);
e.printStackTrace();
}
return jsonResult;
}
/**
* 获取数据源表字段
*
......
......@@ -18,12 +18,16 @@ import java.io.Serializable;
@ApiModel("授权api列表请求对象")
public class AuthApiListReq extends BasePageBean implements Serializable {
@ApiModelProperty(value = "文件夹id", required = false)
@ApiModelProperty(value = "文件夹id",required = false)
private Long fileId;
@ApiModelProperty(value = "组织编码", required = false)
@ApiModelProperty(value = "文件来源:,1 API制做,2 组织创建",required = false)
private String fileSource;
@ApiModelProperty(value = "组织编码",required = false)
private String orgCode;
@ApiModelProperty(value = "组织名称", required = false)
@ApiModelProperty(value = "组织名称",required = false)
private String orgName;
@ApiModelProperty(value = "api名称", required = false)
@ApiModelProperty(value = "api名称",required = false)
private String apiName;
@ApiModelProperty(value = "项目id")
private Long projectId;
}
......@@ -24,7 +24,7 @@ public class CreateFolderReq implements Serializable {
@ApiModelProperty(value = "项目id", required = false)
private Long projectId;
@ApiModelProperty(value = "组织编码", required = false)
@ApiModelProperty(value = "组织编码/编辑时不允许修改", required = false)
private String orgCode;
@ApiModelProperty(value = "父类文件夹id ,创建同级不传", required = false)
......@@ -40,8 +40,14 @@ public class CreateFolderReq implements Serializable {
@NotNull(message = "文件来源不能为空")
private String fileSource;
@ApiModelProperty(value = "创建用户", required = false)
private String createUser;
//---------------------------------更新时id必传------------------
@ApiModelProperty(value = "文件id", required = false)
private String id;
@ApiModelProperty(value = "更新用户", required = false)
private String updateUser;
}
......@@ -24,9 +24,20 @@ public class LogInfoListReq extends BasePageBean implements Serializable {
@ApiModelProperty(value = "客户请求token")
private String requestToken;
@ApiModelProperty(value = "开始时间")
private String startDate;
@ApiModelProperty(value = "结束时间")
private String endDate;
@ApiModelProperty(value = "状态:SUCCEED 请求成功, FAIL 请求失败")
private String status;
@ApiModelProperty(value = "创建时间")
private String createDate;
@ApiModelProperty(value = "历史查询-数据银行")
private String historyQuery;
}
......@@ -27,4 +27,10 @@ public class OrganizationManageListQueryReq extends BasePageBean implements Seri
@ApiModelProperty(value = "联系人")
private String linkman;
@ApiModelProperty(value = "文件夹id")
private String fileId;
@ApiModelProperty(value = "工程id")
private Long projectId;
}
......@@ -195,4 +195,13 @@ public interface DmpRealtimeSyncInfoDao {
* @since 2021-02-02
*/
int insertRealtimeHistory(DmpRealtimeTaskHistory taskHistory) throws Exception;
/**
* 获取实时任务状态
*
* @return
* @author Bellamy
* @since 2021-02-02
*/
Map<String, Object> queryTaskStatus(String projectId) throws Exception;
}
\ No newline at end of file
......@@ -68,7 +68,7 @@ public interface DmpApiMangeService {
* @author Bellamy
* @since 2021-01-19
*/
JsonResult apiTestInfo(Map<String,Object> params) throws Exception;
JsonResult apiTestInfo(Map<String,String> params) throws Exception;
/**
* 查看日志
......@@ -132,4 +132,20 @@ public interface DmpApiMangeService {
* @since 2021-02-20
*/
JsonResult logDetails(String id) throws Exception;
/**
* 授权--组织名称查询
*
* @author Bellamy
* @since 2021-03-02
*/
JsonResult getAuthOrgName(String orgName) throws Exception;
/**
* API测试--下拉框
*
* @author Bellamy
* @since 2021-03-03
*/
JsonResult getApiTestGetApiKey(String apiName) throws Exception;
}
......@@ -97,7 +97,7 @@ public interface DmpApiServiceMangeService {
* @author Bellamy
* @since 2021-02-24
*/
JsonResult getFolderTree(String projectId, String orgCode) throws Exception;
JsonResult getFolderTree(String projectId, String orgFolder) throws Exception;
/**
* API计量--API已调用列表
......@@ -122,4 +122,22 @@ public interface DmpApiServiceMangeService {
* @since 2021-02-24
*/
JsonResult createProjectFolder(CreateFolderReq req) throws Exception;
/**
* 删除文件夹
*
* @return
* @author Bellamy
* @since 2021-03-3
*/
JsonResult delFolderById(String id) throws Exception;
/**
* 获取function模板列表
*
* @return
* @author Bellamy
* @since 2021-03-3
*/
JsonResult getFunctionTemplateList() throws Exception;
}
\ No newline at end of file
......@@ -174,4 +174,13 @@ public interface DmpDevelopTaskService {
* @since 2021-02-03
*/
JsonResult queryExamplesLogByExecId(String execId) throws Exception;
/**
* 运维大屏--获取任务状态
*
* @return
* @author Bellamy
* @since 2021-02-22
*/
JsonResult getTaskStatus(String projectId) throws Exception;
}
\ No newline at end of file
......@@ -130,4 +130,12 @@ public interface OfflineSynchService {
* @since 2021-02-19
*/
JsonResult getDataPreview(OfflineDataPreview req) throws Exception;
/**
* sync-获取数据源表字段
*
* @return
* @author Bellamy
*/
JsonResult getSyncSoureAndTargetColumns(Map<String, List<SynchTableColumnsReq>> req) throws Exception;
}
package com.jz.dmp.modules.service.impl;
import com.alibaba.fastjson.JSONObject;
import com.jz.common.constant.CommConstant;
import com.jz.common.constant.GatewayApiConstant;
import com.jz.common.constant.JsonResult;
import com.jz.common.constant.ResultCode;
import com.jz.common.utils.FreeMarkerUtils;
import com.jz.common.utils.MD5SignUtils;
import com.jz.common.utils.MapUtil;
import com.jz.common.utils.web.HttpClientUtils;
import com.jz.dmp.modules.controller.dataService.bean.*;
import com.jz.dmp.modules.service.DmpApiMangeService;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import org.springframework.web.servlet.view.freemarker.FreeMarkerConfig;
import java.util.HashMap;
import java.util.Map;
......@@ -31,6 +37,9 @@ public class DmpApiMangeServiceImpl implements DmpApiMangeService {
@Value("${spring.gateway-url}")
private String gatewayUrl;
@Autowired
private FreeMarkerConfig freeMarkerConfig;
/**
* 授权给他人的API-列表分页查询
*
......@@ -193,12 +202,49 @@ public class DmpApiMangeServiceImpl implements DmpApiMangeService {
* @since 2021-01-19
*/
@Override
public JsonResult apiTestInfo(Map<String, Object> params) throws Exception {
public JsonResult apiTestInfo(Map<String, String> params) throws Exception {
String url = gatewayUrl + GatewayApiConstant.testApi;
JsonResult result = GatewayApiConstant.postRequest2GetData(url, JSONObject.toJSONString(params));
if (StringUtils.isEmpty(params.get("apiKey"))) {
return JsonResult.error(ResultCode.PARAMS_ERROR, "apiKey不能为空!");
}
params.put("apiKey", params.get("apiKey"));
params.put("timestamp", String.valueOf(System.currentTimeMillis()));
//使用freemaker模板生成 请求参数
String jsonStr = FreeMarkerUtils.freemakerJson(CommConstant.API_TEST, params, freeMarkerConfig);
Map<String, Object> requestJson = (Map<String, Object>) JSONObject.parse(jsonStr);
//对签约参数进行字典排序
String signParams = MapUtil.stringNormalSort(assembleSignMap(requestJson));
if (StringUtils.isNotEmpty(signParams)) {
String sign = MD5SignUtils.encrypt(signParams, "");
requestJson.put("sign", sign);
}
JsonResult result = GatewayApiConstant.postRequest2GetData(url, JSONObject.toJSONString(requestJson));
if (null == result.getData()) {
throw new RuntimeException("failed!");
}
Map<String, Object> data = (Map<String, Object>) result.getData();
result.setData(data.get("response_result"));
return result;
}
/**
* 组装签名参数
*
* @param params
* @return
*/
private Map assembleSignMap(Map<String, Object> params) {
Map<String, String> paramsMap = new HashMap<>();
paramsMap.put("apiKey", (String) params.get("apiKey"));
paramsMap.put("method", (String) params.get("method"));
paramsMap.put("signType", (String) params.get("signType"));
paramsMap.put("params", JSONObject.toJSONString(params.get("params")));
return paramsMap;
}
/**
* 查看日志
*
......@@ -207,26 +253,8 @@ public class DmpApiMangeServiceImpl implements DmpApiMangeService {
*/
@Override
public JsonResult checkApiLogInfo(LogInfoListReq req) throws Exception {
JsonResult result = new JsonResult();
String url = gatewayUrl + GatewayApiConstant.checkApiLog;
String resultData = HttpClientUtils.post(url, JSONObject.toJSONString(req));
if (StringUtils.isEmpty(resultData)) {
throw new RuntimeException("查询失败!");
}
logger.info("#################响应结果数据{}" + resultData);
Map jsonObject = JSONObject.parseObject(resultData);
if (jsonObject.containsKey("code")) {
if ("200".equals(jsonObject.get("code").toString())) {
result.setData(jsonObject.get("data"));
return result;
}
}
if (jsonObject.containsKey("msg")) {
logger.info(jsonObject.get("msg").toString());
result.setCode(ResultCode.INTERNAL_SERVER_ERROR);
result.setMessage(jsonObject.get("msg").toString());
}
JsonResult result = GatewayApiConstant.postRequest2GetData(url, JSONObject.toJSONString(req));
return result;
}
......@@ -425,4 +453,35 @@ public class DmpApiMangeServiceImpl implements DmpApiMangeService {
return result;
}
/**
* 授权--组织名称查询
*
* @param orgName
* @author Bellamy
* @since 2021-03-02
*/
@Override
public JsonResult getAuthOrgName(String orgName) throws Exception {
String url = gatewayUrl + GatewayApiConstant.getOrgNameList;
Map params = new HashMap();
params.put("orgName", orgName);
JsonResult result = GatewayApiConstant.getRequest2GetData(url, params);
return result;
}
/**
* API测试--下拉框
*
* @author Bellamy
* @since 2021-03-03
*/
@Override
public JsonResult getApiTestGetApiKey(String apiName) throws Exception {
String url = gatewayUrl + GatewayApiConstant.listGetApiKey;
Map params = new HashMap();
params.put("apiName", apiName);
JsonResult result = GatewayApiConstant.getRequest2GetData(url, params);
return result;
}
}
......@@ -241,10 +241,45 @@ public class DmpApiServiceMangeServiceImpl implements DmpApiServiceMangeService
public JsonResult createProjectFolder(CreateFolderReq req) throws Exception {
String url = gatewayUrl + GatewayApiConstant.createProjectFolder;
req.setCreateUser(SessionUtils.getCurrentUserName());
if (StringUtils.isNotEmpty(req.getId())) {
req.setUpdateUser(SessionUtils.getCurrentUserName());
}
JsonResult result = GatewayApiConstant.postRequest2GetData(url, JSONObject.toJSONString(req));
return result;
}
/**
* 删除文件夹
*
* @param id
* @return
* @author Bellamy
* @since 2021-03-3
*/
@Override
public JsonResult delFolderById(String id) throws Exception {
String url = gatewayUrl + GatewayApiConstant.delFolder;
Map params = new HashMap();
params.put("id", id);
JsonResult result = GatewayApiConstant.getRequest2GetData(url, params);
return result;
}
/**
* 获取function模板列表
*
* @return
* @author Bellamy
* @since 2021-03-3
*/
@Override
public JsonResult getFunctionTemplateList() throws Exception {
String url = gatewayUrl + GatewayApiConstant.functionTemplate;
Map params = new HashMap();
JsonResult result = GatewayApiConstant.getRequest2GetData(url, params);
return result;
}
/**
* 服务开发API列表
*
......@@ -269,31 +304,15 @@ public class DmpApiServiceMangeServiceImpl implements DmpApiServiceMangeService
* @since 2021-02-24
*/
@Override
public JsonResult getFolderTree(String projectId, String orgCode) throws Exception {
JsonResult result = new JsonResult();
public JsonResult getFolderTree(String projectId, String orgFolder) throws Exception {
String url = gatewayUrl + GatewayApiConstant.folderTree;
Map params = new HashMap();
if (StringUtils.isNotEmpty(projectId)) {
params.put("projectId", projectId);
}
params.put("orgCode", orgCode);
String returnData = HttpClientUtils.getJsonForParam(url, params);
if (StringUtils.isEmpty(returnData)) {
throw new RuntimeException("查询失败!");
}
logger.info("#################响应结果{}" + returnData);
Map map = JSONObject.parseObject(returnData);
if (map.containsKey("code")) {
if ("200".equals(map.get("code").toString())) {
return JsonResult.ok(map.get("data"));
}
}
if (map.containsKey("msg")) {
logger.info(map.get("msg").toString());
result.setMessage(map.get("msg").toString());
result.setCode(ResultCode.INTERNAL_SERVER_ERROR);
}
params.put("orgFolder", orgFolder);
JsonResult result = GatewayApiConstant.getRequest2GetData(url, params);
return result;
}
......
package com.jz.dmp.modules.service.impl;
import java.io.File;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.regex.Pattern;
import javax.servlet.http.HttpServletRequest;
import com.alibaba.fastjson.JSONObject;
import com.mysql.jdbc.Blob;
import org.apache.tomcat.jni.Mmap;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.aop.ThrowsAdvice;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.node.ObjectNode;
import com.github.pagehelper.Page;
......@@ -40,15 +15,7 @@ import com.jz.common.constant.StatuConstant;
import com.jz.common.enums.ModuleLogEnum;
import com.jz.common.page.PageInfoResponse;
import com.jz.common.persistence.BaseService;
import com.jz.common.utils.AzkabanApiUtils2;
import com.jz.common.utils.CodeGeneratorUtils;
import com.jz.common.utils.DateUtils;
import com.jz.common.utils.FileUtils;
import com.jz.common.utils.FlowParseTool;
import com.jz.common.utils.GZIPUtils;
import com.jz.common.utils.JsonMapper;
import com.jz.common.utils.StringUtils;
import com.jz.common.utils.ZipUtils;
import com.jz.common.utils.*;
import com.jz.common.utils.web.XmlUtils;
import com.jz.dmp.agent.DmpAgentResult;
import com.jz.dmp.azkaban.dao.ExecutionFlowsMapper;
......@@ -62,27 +29,25 @@ import com.jz.dmp.modules.controller.dataOperation.bean.DataDevExamplesListReq;
import com.jz.dmp.modules.controller.dataOperation.bean.DataDevTaskListDto;
import com.jz.dmp.modules.controller.dataOperation.bean.DataDevTaskListReq;
import com.jz.dmp.modules.controller.projconfig.bean.DmpProjectConfigInfoDto;
import com.jz.dmp.modules.dao.DmpDevelopTaskDao;
import com.jz.dmp.modules.dao.DmpNavigationTreeDao;
import com.jz.dmp.modules.dao.DmpProjectDao;
import com.jz.dmp.modules.dao.DmpSyncingDatasourceTypeDao;
import com.jz.dmp.modules.dao.*;
import com.jz.dmp.modules.dao.projconfig.DmpProjectConfigInfoMapper;
import com.jz.dmp.modules.model.DmpAgentDatasourceInfo;
import com.jz.dmp.modules.model.DmpDevelopTask;
import com.jz.dmp.modules.model.DmpDevelopTaskHistory;
import com.jz.dmp.modules.model.DmpModuleOperateLog;
import com.jz.dmp.modules.model.DmpNavigationTree;
import com.jz.dmp.modules.model.DmpProjectConfigInfo;
import com.jz.dmp.modules.model.DmpProjectSystemInfo;
import com.jz.dmp.modules.model.DmpSyncingDatasource;
import com.jz.dmp.modules.model.DmpSyncingDatasourceType;
import com.jz.dmp.modules.service.DmpDevelopTaskHistoryService;
import com.jz.dmp.modules.service.DmpDevelopTaskService;
import com.jz.dmp.modules.service.DmpModuleOperateLogService;
import com.jz.dmp.modules.service.DmpSyncingDatasourceService;
import com.jz.dmp.modules.service.FlowService;
import com.jz.dmp.modules.service.OfflineSynchService;
import com.jz.dmp.modules.service.projconfig.DmpProjectConfigInfoService;
import com.jz.dmp.modules.model.*;
import com.jz.dmp.modules.service.*;
import org.apache.hadoop.yarn.webapp.hamlet.Hamlet;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;
import javax.servlet.http.HttpServletRequest;
import java.io.File;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.util.*;
import java.util.regex.Pattern;
/**
* 任务开发(DmpDevelopTask)表服务实现类
......@@ -116,28 +81,31 @@ public class DmpDevelopTaskServiceImpl extends BaseService implements DmpDevelop
@Autowired
private ExecutionFlowsMapper executionFlowsMapper;
@Autowired
private DmpModuleOperateLogService dmpModuleOperateLogService;
@Autowired
private DmpNavigationTreeDao dmpNavigationTreeDao;
@Autowired
private ObjectMapper objectMapper;
@Autowired
private FlowService flowService;
@Autowired
private DmpDevelopTaskHistoryService dmpDevelopTaskHistoryService;
@Autowired
private DmpProjectConfigInfoMapper dmpProjectConfigInfoMapper;
@Autowired
private RedisTemplate redisTemplate;
@Autowired
private DmpRealtimeSyncInfoDao dmpRealtimeSyncInfoDao;
/**
* 添加保存dmp数据(包含校验数据)
*
......@@ -810,6 +778,7 @@ public class DmpDevelopTaskServiceImpl extends BaseService implements DmpDevelop
public PageInfoResponse<DataDevTaskListDto> queryDevTaskListPage(DataDevTaskListReq req) throws Exception {
PageInfoResponse<DataDevTaskListDto> pageInfoResponse = new PageInfoResponse<>();
if (StringUtils.isNotBlank(req.getTreeIdOrName())) {
//判断是否为整数 是整数返回true,否则返回false
Pattern pattern = Pattern.compile("^[-\\+]?[\\d]*$");
......@@ -828,6 +797,13 @@ public class DmpDevelopTaskServiceImpl extends BaseService implements DmpDevelop
pageInfoResponse.setCode(ResultCode.SUCCESS);
pageInfoResponse.setMessage("查询成功");
pageInfoResponse.setData(pageInfo);
String taskName = "";
List<DataDevTaskListDto> listObj = (List<DataDevTaskListDto>) pageInfo;
for (DataDevTaskListDto str : listObj) {
taskName += "," + str.getTaskName();
}
List<Map> flowList = executionFlowsMapper.queryLastStatus(taskName.substring(1).split(","));
return pageInfoResponse;
}
......@@ -982,17 +958,17 @@ public class DmpDevelopTaskServiceImpl extends BaseService implements DmpDevelop
}
//未删除数据
param.put("dataStatus", "1");
String obderByStr = dmpDevelopTaskRequest.takeOrderByStr(DmpDevelopTaskRequest.class);
Page page = null;
if (obderByStr==null) {
page = PageHelper.startPage(dmpDevelopTaskRequest.getPageNum(), dmpDevelopTaskRequest.getPageSize());
} else {
page = PageHelper.startPage(dmpDevelopTaskRequest.getPageNum(), dmpDevelopTaskRequest.getPageSize(), obderByStr);
}
if (obderByStr == null) {
page = PageHelper.startPage(dmpDevelopTaskRequest.getPageNum(), dmpDevelopTaskRequest.getPageSize());
} else {
page = PageHelper.startPage(dmpDevelopTaskRequest.getPageNum(), dmpDevelopTaskRequest.getPageSize(), obderByStr);
}
List<DmpDevelopTask> list = dmpDevelopTaskDao.findList(param);
List<DmpDevelopTaskDto> dtos = MyDmpDevelopTaskConverter.INSTANCE().domain2dto(list);
PageInfo<DmpDevelopTaskDto> pageInfo = new PageInfo<>(dtos);
......@@ -1046,10 +1022,10 @@ public class DmpDevelopTaskServiceImpl extends BaseService implements DmpDevelop
//通过任务名称,去查询开发实例
PageHelper.startPage(req.getPageNum(), req.getPageSize());
Map saveParams = new HashMap();
if (org.apache.commons.lang3.StringUtils.isNotEmpty(req.getBusinessTime())) { //业务时间范围
String[] cretime = req.getBusinessTime().split("-");
saveParams.put("startTime", cretime[0].trim() + " 00:00:00");
saveParams.put("endTime", cretime[1].trim() + " 23:59:59");
if (StringUtils.isNotBlank(req.getStartTime()) && StringUtils.isNotBlank(req.getEndTime())) { //业务时间范围
//String[] cretime = req.getBusinessTime().split("-");
saveParams.put("startTime", req.getStartTime().trim() + " 00:00:00");
saveParams.put("endTime", req.getEndTime().trim() + " 23:59:59");
} else if (StringUtils.isNotBlank(req.getCreTimeType())) {
if ("01".equals(req.getCreTimeType())) { //昨天
saveParams.put("businessTime", DateUtils.getYesterdayStr());
......@@ -1085,9 +1061,9 @@ public class DmpDevelopTaskServiceImpl extends BaseService implements DmpDevelop
}
return pageInfoResponse;
}
/**
*根据treeId取得最新版提交的同步脚本文件名(不含后缀)及版本信息
* 根据treeId取得最新版提交的同步脚本文件名(不含后缀)及版本信息
*/
@Override
public String getConfigFileNameNotSuffix4Published(Long treeId) throws Exception {
......@@ -1095,8 +1071,8 @@ public class DmpDevelopTaskServiceImpl extends BaseService implements DmpDevelop
String fileName = XmlUtils.getPropertyValue(log.getOperateLog(), "name");
return fileName + "@" + log.getRemark();
}
private DmpModuleOperateLog getLastVersion4SubmitSyncInfo(Integer treeId)throws Exception {
private DmpModuleOperateLog getLastVersion4SubmitSyncInfo(Integer treeId) throws Exception {
DmpModuleOperateLog o = null;
try {
o = dmpModuleOperateLogService.getLastOperateLog(treeId, ModuleLogEnum.VERSION_SYNC_XML);
......@@ -1117,48 +1093,48 @@ public class DmpDevelopTaskServiceImpl extends BaseService implements DmpDevelop
}
return o;
}
/*
* (non-Javadoc)
*
* @see
* com.ycxc.vmts.service.DmpDevelopTaskService#add(com.ycxc.vmts.entity.DmpDevelopTask,
* javax.servlet.http.HttpServletRequest)
*/
@Override
@Transactional(rollbackFor = Exception.class)
public BaseBeanResponse<DmpDevelopTask> add(DmpDevelopTask dmpDevelopTask, HttpServletRequest httpRequest) throws Exception {
BaseBeanResponse<DmpDevelopTask> baseBeanResponse = new BaseBeanResponse<>();
//参数校验
String taskName = dmpDevelopTask.getName();
if (StringUtils.isEmpty(taskName)) {
baseBeanResponse.setCode(StatuConstant.CODE_ERROR_PARAMETER);
baseBeanResponse.setMessage("任务名称不能为空");
return baseBeanResponse;
}
//任务类型校验
String taskType = dmpDevelopTask.getTaskType();
String treeType = "";
if (StringUtils.isEmpty(taskType)) {
baseBeanResponse.setCode(StatuConstant.CODE_ERROR_PARAMETER);
baseBeanResponse.setMessage("任务类型不能为空");
return baseBeanResponse;
} else if (taskType.equals(CommConstant.TASK_TYPE_DEVELOP)) {
treeType = CommConstant.TREE_TYPE_DEVELOP;
} else if (taskType.equals(CommConstant.TASK_TYPE_DEVSHELL)) {
treeType = CommConstant.TREE_TYPE_DEVSHELL;
} else if (taskType.equals(CommConstant.TASK_TYPE_DEVSQL)) {
treeType = CommConstant.TREE_TYPE_DEVSQL;
} else {
baseBeanResponse.setCode(StatuConstant.CODE_ERROR_PARAMETER);
baseBeanResponse.setMessage("任务类型错误");
return baseBeanResponse;
}
//添加树叶子节点
DmpNavigationTree tree = new DmpNavigationTree();
* (non-Javadoc)
*
* @see
* com.ycxc.vmts.service.DmpDevelopTaskService#add(com.ycxc.vmts.entity.DmpDevelopTask,
* javax.servlet.http.HttpServletRequest)
*/
@Override
@Transactional(rollbackFor = Exception.class)
public BaseBeanResponse<DmpDevelopTask> add(DmpDevelopTask dmpDevelopTask, HttpServletRequest httpRequest) throws Exception {
BaseBeanResponse<DmpDevelopTask> baseBeanResponse = new BaseBeanResponse<>();
//参数校验
String taskName = dmpDevelopTask.getName();
if (StringUtils.isEmpty(taskName)) {
baseBeanResponse.setCode(StatuConstant.CODE_ERROR_PARAMETER);
baseBeanResponse.setMessage("任务名称不能为空");
return baseBeanResponse;
}
//任务类型校验
String taskType = dmpDevelopTask.getTaskType();
String treeType = "";
if (StringUtils.isEmpty(taskType)) {
baseBeanResponse.setCode(StatuConstant.CODE_ERROR_PARAMETER);
baseBeanResponse.setMessage("任务类型不能为空");
return baseBeanResponse;
} else if (taskType.equals(CommConstant.TASK_TYPE_DEVELOP)) {
treeType = CommConstant.TREE_TYPE_DEVELOP;
} else if (taskType.equals(CommConstant.TASK_TYPE_DEVSHELL)) {
treeType = CommConstant.TREE_TYPE_DEVSHELL;
} else if (taskType.equals(CommConstant.TASK_TYPE_DEVSQL)) {
treeType = CommConstant.TREE_TYPE_DEVSQL;
} else {
baseBeanResponse.setCode(StatuConstant.CODE_ERROR_PARAMETER);
baseBeanResponse.setMessage("任务类型错误");
return baseBeanResponse;
}
//添加树叶子节点
DmpNavigationTree tree = new DmpNavigationTree();
tree.setName(taskName);
tree.setParentId(dmpDevelopTask.getParentId());
tree.setProjectId(dmpDevelopTask.getProjectId());
......@@ -1168,15 +1144,15 @@ public class DmpDevelopTaskServiceImpl extends BaseService implements DmpDevelop
tree.setIsEnable("1");
tree.setDataStatus("1");
tree.setTreeSort(dmpNavigationTreeDao.getMaxSortById(tree));
int cnt = dmpNavigationTreeDao.countTreeByName(tree);
if (cnt > 0) {
baseBeanResponse.setCode(StatuConstant.CODE_DATA_EXISTED);
baseBeanResponse.setMessage("当前项目已存在同名的任务名称");
return baseBeanResponse;
baseBeanResponse.setCode(StatuConstant.CODE_DATA_EXISTED);
baseBeanResponse.setMessage("当前项目已存在同名的任务名称");
return baseBeanResponse;
}
dmpNavigationTreeDao.insert(tree);
//将新增任务保存到数据库
dmpDevelopTask.setTaskType(taskType);
dmpDevelopTask.setType("W");
......@@ -1187,7 +1163,7 @@ public class DmpDevelopTaskServiceImpl extends BaseService implements DmpDevelop
int revision = 1;
ObjectNode flowHeaderNode = objectMapper.createObjectNode();
flowHeaderNode.put("name", dmpDevelopTask.getName() );
flowHeaderNode.put("name", dmpDevelopTask.getName());
flowHeaderNode.put("description", dmpDevelopTask.getTaskDesc());
flowHeaderNode.put("revision", revision);
dmpDevelopTask.setFlowHeader(flowHeaderNode.toString());
......@@ -1196,7 +1172,7 @@ public class DmpDevelopTaskServiceImpl extends BaseService implements DmpDevelop
scriptNode.put("id", "canvas");
scriptNode.put("resourceId", "canvas");
ObjectNode stencilSetNode = objectMapper.createObjectNode();
stencilSetNode.put("namespace","http://b3mn.org/stencilset/bpmn2.0#");
stencilSetNode.put("namespace", "http://b3mn.org/stencilset/bpmn2.0#");
scriptNode.put("stencilset", stencilSetNode);
byte[] data = null;
try {
......@@ -1206,105 +1182,105 @@ public class DmpDevelopTaskServiceImpl extends BaseService implements DmpDevelop
}
dmpDevelopTask.setData(data);
// 创建人
dmpDevelopTask.setCreateUserId(Optional.ofNullable(getHttpRequestUserId(httpRequest)).orElse(0).toString());
// 创建时间
dmpDevelopTask.setCreateTime(new Date());
//版本设置
//获取已存在版本
String version = CodeGeneratorUtils.generatorNextTaskVesion(null);
dmpDevelopTask.setVersion(version);
dmpDevelopTaskDao.insert(dmpDevelopTask);
baseBeanResponse.setCode(StatuConstant.SUCCESS_CODE);
baseBeanResponse.setMessage("新增成功");
baseBeanResponse.setData(dmpDevelopTask);
return baseBeanResponse;
}
/*
* (non-Javadoc)
*
* @see
* com.ycxc.vmts.service.DmpDevelopTaskService#findByTreeId(com.ycxc.vmts.controller.
* bean.DmpDevelopTaskRequest, javax.servlet.http.HttpServletRequest)
*/
@Override
public BaseBeanResponse<DmpDevelopTaskDto> findByTreeId(Integer treeId, HttpServletRequest httpRequest)
throws Exception {
BaseBeanResponse<DmpDevelopTaskDto> baseBeanResponse = new BaseBeanResponse<>();
DmpDevelopTask dmpDevelopTask = dmpDevelopTaskDao.selectTaskInfoByParam(treeId);
DmpDevelopTaskDto dmpDevelopTaskDto = MyDmpDevelopTaskConverter.INSTANCE().domain2dto(dmpDevelopTask);
baseBeanResponse.setCode(StatuConstant.SUCCESS_CODE);
baseBeanResponse.setMessage("查询成功");
baseBeanResponse.setData(dmpDevelopTaskDto);
return baseBeanResponse;
}
/**
*任务修改
*/
@Override
@Transactional(rollbackFor = Exception.class)
public BaseBeanResponse<DmpDevelopTask> edit(DmpDevelopTask dmpDevelopTask, HttpServletRequest httpRequest)
throws Exception {
BaseBeanResponse<DmpDevelopTask> baseBeanResponse = new BaseBeanResponse<DmpDevelopTask>();
// 修改人
dmpDevelopTask.setUpdateUserId(getHttpRequestUserId(httpRequest).toString());
// 修改时间
dmpDevelopTask.setUpdateTime(new Date());
// 版本设置
// 获取已存在版本
DmpDevelopTask dmpDevelopTaskDb = dmpDevelopTaskDao.selectTaskById(dmpDevelopTask.getId().toString());
String version = CodeGeneratorUtils.generatorNextTaskVesion(dmpDevelopTaskDb.getVersion());
dmpDevelopTask.setVersion(version);
dmpDevelopTaskDao.update(dmpDevelopTask);
DmpDevelopTask dmpDevelopTaskDb2 = dmpDevelopTaskDao.selectTaskById(dmpDevelopTask.getId().toString());
DmpDevelopTaskHistory dmpDevelopTaskHistory = MyDmpDevelopTaskHistoryConverter.INSTANCE().task2history(dmpDevelopTaskDb2);
// 保存版本为版本数据
dmpDevelopTaskHistoryService.add(dmpDevelopTaskHistory, httpRequest);
baseBeanResponse.setCode(StatuConstant.SUCCESS_CODE);
baseBeanResponse.setMessage("修改成功");
baseBeanResponse.setData(dmpDevelopTaskDb2);
return baseBeanResponse;
}
/**
*任务流程发布
*/
@Override
public BaseResponse flowSubmit(Long treeId, HttpServletRequest httpRequest)
throws Exception {
BaseResponse baseResponse = new BaseResponse();
// 参数校验
if (treeId == null) {
baseResponse.setCode(StatuConstant.CODE_ERROR_PARAMETER);
baseResponse.setMessage("treeId不能为空");
return baseResponse;
}
DmpDevelopTask dmpDevelopTask = dmpDevelopTaskDao.get(treeId);
FlowPro flowPro = MyDmpDevelopTaskConverter.INSTANCE().task2flowpro(dmpDevelopTask);
// 创建人
dmpDevelopTask.setCreateUserId(Optional.ofNullable(getHttpRequestUserId(httpRequest)).orElse(0).toString());
// 创建时间
dmpDevelopTask.setCreateTime(new Date());
//版本设置
//获取已存在版本
String version = CodeGeneratorUtils.generatorNextTaskVesion(null);
dmpDevelopTask.setVersion(version);
dmpDevelopTaskDao.insert(dmpDevelopTask);
baseBeanResponse.setCode(StatuConstant.SUCCESS_CODE);
baseBeanResponse.setMessage("新增成功");
baseBeanResponse.setData(dmpDevelopTask);
return baseBeanResponse;
}
/*
* (non-Javadoc)
*
* @see
* com.ycxc.vmts.service.DmpDevelopTaskService#findByTreeId(com.ycxc.vmts.controller.
* bean.DmpDevelopTaskRequest, javax.servlet.http.HttpServletRequest)
*/
@Override
public BaseBeanResponse<DmpDevelopTaskDto> findByTreeId(Integer treeId, HttpServletRequest httpRequest)
throws Exception {
BaseBeanResponse<DmpDevelopTaskDto> baseBeanResponse = new BaseBeanResponse<>();
DmpDevelopTask dmpDevelopTask = dmpDevelopTaskDao.selectTaskInfoByParam(treeId);
DmpDevelopTaskDto dmpDevelopTaskDto = MyDmpDevelopTaskConverter.INSTANCE().domain2dto(dmpDevelopTask);
baseBeanResponse.setCode(StatuConstant.SUCCESS_CODE);
baseBeanResponse.setMessage("查询成功");
baseBeanResponse.setData(dmpDevelopTaskDto);
return baseBeanResponse;
}
/**
* 任务修改
*/
@Override
@Transactional(rollbackFor = Exception.class)
public BaseBeanResponse<DmpDevelopTask> edit(DmpDevelopTask dmpDevelopTask, HttpServletRequest httpRequest)
throws Exception {
BaseBeanResponse<DmpDevelopTask> baseBeanResponse = new BaseBeanResponse<DmpDevelopTask>();
// 修改人
dmpDevelopTask.setUpdateUserId(getHttpRequestUserId(httpRequest).toString());
// 修改时间
dmpDevelopTask.setUpdateTime(new Date());
// 版本设置
// 获取已存在版本
DmpDevelopTask dmpDevelopTaskDb = dmpDevelopTaskDao.selectTaskById(dmpDevelopTask.getId().toString());
String version = CodeGeneratorUtils.generatorNextTaskVesion(dmpDevelopTaskDb.getVersion());
dmpDevelopTask.setVersion(version);
dmpDevelopTaskDao.update(dmpDevelopTask);
DmpDevelopTask dmpDevelopTaskDb2 = dmpDevelopTaskDao.selectTaskById(dmpDevelopTask.getId().toString());
DmpDevelopTaskHistory dmpDevelopTaskHistory = MyDmpDevelopTaskHistoryConverter.INSTANCE().task2history(dmpDevelopTaskDb2);
// 保存版本为版本数据
dmpDevelopTaskHistoryService.add(dmpDevelopTaskHistory, httpRequest);
baseBeanResponse.setCode(StatuConstant.SUCCESS_CODE);
baseBeanResponse.setMessage("修改成功");
baseBeanResponse.setData(dmpDevelopTaskDb2);
return baseBeanResponse;
}
/**
* 任务流程发布
*/
@Override
public BaseResponse flowSubmit(Long treeId, HttpServletRequest httpRequest)
throws Exception {
BaseResponse baseResponse = new BaseResponse();
// 参数校验
if (treeId == null) {
baseResponse.setCode(StatuConstant.CODE_ERROR_PARAMETER);
baseResponse.setMessage("treeId不能为空");
return baseResponse;
}
DmpDevelopTask dmpDevelopTask = dmpDevelopTaskDao.get(treeId);
FlowPro flowPro = MyDmpDevelopTaskConverter.INSTANCE().task2flowpro(dmpDevelopTask);
DmpNavigationTree dmpNavigationTree = dmpNavigationTreeDao.queryById(treeId.intValue());
Long projectId = Long.parseLong(dmpNavigationTree.getProjectId().toString());
flowPro.setPublishedToProjectId(projectId);
......@@ -1326,93 +1302,93 @@ public class DmpDevelopTaskServiceImpl extends BaseService implements DmpDevelop
}
updateDevelopTask.setIsSubmit(flowPro.getIsSubmit());
updateDevelopTask.setIsGziped(1);
//设置发布版本
updateDevelopTask.setPublishVersion(queryDmpDevelopTask.getVersion());
dmpDevelopTaskDao.update(updateDevelopTask);
baseResponse.setCode(StatuConstant.SUCCESS_CODE);
baseResponse.setMessage("工作流程保存发布成功");
} else {
baseResponse.setCode(StatuConstant.SUCCESS_CODE);
baseResponse.setCode(StatuConstant.SUCCESS_CODE);
baseResponse.setMessage(baseResponsePublish.getMessage());
}
return baseResponse;
}
/**
*根据treeId获取离线任务xmlFileName
*/
@Override
public String getExecXmlFileName(Long syncTaskTreeId) throws Exception {
DmpDevelopTask dmpDevelopTask = dmpDevelopTaskDao.selectTaskInfoByParam(syncTaskTreeId);
if (!dmpDevelopTask.getTaskType().equals(CommConstant.TASK_TYPE_OFFLINE)) {
throw new RuntimeException("非离线任务!");
}
String xmlContent = convert2SyncXmlContent(dmpDevelopTask);
String xmlFileName = XmlUtils.getPropertyValue(xmlContent, "name");
return xmlFileName;
}
/**
*运行任务
*/
@Override
public BaseResponse taskAzkabanRun(Long treeId, HttpServletRequest httpRequest) throws Exception {
BaseResponse baseResponse = new BaseResponse();
DmpDevelopTask developTask = dmpDevelopTaskDao.get(treeId);
//先发布任务
boolean flag = publishAndExecute(developTask);
if (flag) {
baseResponse.setCode(StatuConstant.SUCCESS_CODE);
baseResponse.setMessage("立即运行成功");
} else {
baseResponse.setCode(StatuConstant.FAILURE_CODE);
baseResponse.setMessage("立即运行失败");
}
return baseResponse;
}
/**
}
return baseResponse;
}
/**
* 根据treeId获取离线任务xmlFileName
*/
@Override
public String getExecXmlFileName(Long syncTaskTreeId) throws Exception {
DmpDevelopTask dmpDevelopTask = dmpDevelopTaskDao.selectTaskInfoByParam(syncTaskTreeId);
if (!dmpDevelopTask.getTaskType().equals(CommConstant.TASK_TYPE_OFFLINE)) {
throw new RuntimeException("非离线任务!");
}
String xmlContent = convert2SyncXmlContent(dmpDevelopTask);
String xmlFileName = XmlUtils.getPropertyValue(xmlContent, "name");
return xmlFileName;
}
/**
* 运行任务
*/
@Override
public BaseResponse taskAzkabanRun(Long treeId, HttpServletRequest httpRequest) throws Exception {
BaseResponse baseResponse = new BaseResponse();
DmpDevelopTask developTask = dmpDevelopTaskDao.get(treeId);
//先发布任务
boolean flag = publishAndExecute(developTask);
if (flag) {
baseResponse.setCode(StatuConstant.SUCCESS_CODE);
baseResponse.setMessage("立即运行成功");
} else {
baseResponse.setCode(StatuConstant.FAILURE_CODE);
baseResponse.setMessage("立即运行失败");
}
return baseResponse;
}
/**
* 发布流程
*/
private boolean publishAndExecute(DmpDevelopTask dmpDevelopTask) throws Exception {
Integer taskId = dmpDevelopTask.getId(); //任务id
Integer projectId = dmpDevelopTask.getProjectId(); //项目id
String treeName = dmpDevelopTask.getName(); //任务流程名称
//获取项目配置信息
Map<String, Object> param = new HashMap<String, Object>();
param.put("projectId", projectId);
List<DmpProjectConfigInfoDto> list = dmpProjectConfigInfoMapper.findList(param);
if (CollectionUtils.isEmpty(list)) {
throw new RuntimeException("项目没有设置配置信息,请联系管理员!");
}
throw new RuntimeException("项目没有设置配置信息,请联系管理员!");
}
DmpProjectConfigInfoDto dmpProjectConfigInfoDto = list.get(0);
//校验任务类型并配置参数
String taskType = dmpDevelopTask.getTaskType();
String azkabanExectorTaskExec = "";
String taskAlias = "";
if (StringUtils.isEmpty(taskType)) {
throw new RuntimeException("任务的任务类型为空!");
} else if (taskType.equals(CommConstant.TASK_TYPE_DEVSHELL)) {
azkabanExectorTaskExec = dmpProjectConfigInfoDto.getDmpPublicConfigInfoDto().getAzkabanExectorShellExec(); //执行shell任务命令
taskAlias = "shell";
} else if (taskType.equals(CommConstant.TASK_TYPE_DEVSQL)) {
azkabanExectorTaskExec = dmpProjectConfigInfoDto.getDmpPublicConfigInfoDto().getAzkabanExectorSqlExec(); //执行sql任务命令
taskAlias = "sql";
} else {
throw new RuntimeException("该任务类型不能调用此方法发布,请检查任务类型!");
}
throw new RuntimeException("任务的任务类型为空!");
} else if (taskType.equals(CommConstant.TASK_TYPE_DEVSHELL)) {
azkabanExectorTaskExec = dmpProjectConfigInfoDto.getDmpPublicConfigInfoDto().getAzkabanExectorShellExec(); //执行shell任务命令
taskAlias = "shell";
} else if (taskType.equals(CommConstant.TASK_TYPE_DEVSQL)) {
azkabanExectorTaskExec = dmpProjectConfigInfoDto.getDmpPublicConfigInfoDto().getAzkabanExectorSqlExec(); //执行sql任务命令
taskAlias = "sql";
} else {
throw new RuntimeException("该任务类型不能调用此方法发布,请检查任务类型!");
}
String azkabanLocalTaskFilePath = dmpProjectConfigInfoDto.getDmpPublicConfigInfoDto().getAzkabanLocalTaskFilePath(); //文件路径
String azkabanMonitorUrl = dmpProjectConfigInfoDto.getDmpPublicConfigInfoDto().getAzkabanMonitorUrl();//AZKABAN WEB服务地址
......@@ -1466,126 +1442,126 @@ public class DmpDevelopTaskServiceImpl extends BaseService implements DmpDevelop
//上次zip包到azkaban
String localTaskZipAbsolutePath = localTaskZipPath + "/" + localZipTargetFileName;
AzkabanApiUtils2 azkabanApiUtils = new AzkabanApiUtils2(azkabanMonitorUrl, redisTemplate);
return azkabanApiUtils.loginCreateProjectuploadZipAndExecute("jz_localflow_"+taskAlias+"_" + projectId, "local_"+taskAlias+"_project", localTaskZipAbsolutePath, treeName);
return azkabanApiUtils.loginCreateProjectuploadZipAndExecute("jz_localflow_" + taskAlias + "_" + projectId, "local_" + taskAlias + "_project", localTaskZipAbsolutePath, treeName);
}
/**
*停止任务
*/
@Override
public BaseBeanResponse<String> taskAzkabanStop(Long treeId, HttpServletRequest httpRequest) throws Exception {
// TODO Auto-generated method stub
BaseBeanResponse<String> baseBeanResponse = new BaseBeanResponse<String>();
DmpDevelopTask dmpDevelopTask = dmpDevelopTaskDao.get(treeId);
if (dmpDevelopTask==null) {
baseBeanResponse.setCode(StatuConstant.CODE_ERROR_PARAMETER);
baseBeanResponse.setMessage("任务不存在");
return baseBeanResponse;
}
Integer projectId = dmpDevelopTask.getProjectId();
String treeName = dmpDevelopTask.getName();
//获取项目配置信息
/**
* 停止任务
*/
@Override
public BaseBeanResponse<String> taskAzkabanStop(Long treeId, HttpServletRequest httpRequest) throws Exception {
// TODO Auto-generated method stub
BaseBeanResponse<String> baseBeanResponse = new BaseBeanResponse<String>();
DmpDevelopTask dmpDevelopTask = dmpDevelopTaskDao.get(treeId);
if (dmpDevelopTask == null) {
baseBeanResponse.setCode(StatuConstant.CODE_ERROR_PARAMETER);
baseBeanResponse.setMessage("任务不存在");
return baseBeanResponse;
}
Integer projectId = dmpDevelopTask.getProjectId();
String treeName = dmpDevelopTask.getName();
//获取项目配置信息
Map<String, Object> param = new HashMap<String, Object>();
List<DmpProjectConfigInfoDto> list = dmpProjectConfigInfoMapper.findList(param);
if (CollectionUtils.isEmpty(list)) {
throw new RuntimeException("项目没有设置配置信息,请联系管理员!");
}
throw new RuntimeException("项目没有设置配置信息,请联系管理员!");
}
DmpProjectConfigInfoDto dmpProjectConfigInfoDto = list.get(0);
//校验任务类型并配置参数
//校验任务类型并配置参数
String taskType = dmpDevelopTask.getTaskType();
String taskAlias = "";
if (StringUtils.isEmpty(taskType)) {
throw new RuntimeException("任务的任务类型为空!");
} else if (taskType.equals(CommConstant.TASK_TYPE_DEVSHELL)) {
taskAlias = "shell";
} else if (taskType.equals(CommConstant.TASK_TYPE_DEVSQL)) {
taskAlias = "sql";
} else {
throw new RuntimeException("该任务类型不能调用此方法停止,请检查任务类型!");
}
String azkabanMonitorUrl = dmpProjectConfigInfoDto.getDmpPublicConfigInfoDto().getAzkabanMonitorUrl();//AZKABAN WEB服务地址
AzkabanApiUtils2 azkabanApiUtils = new AzkabanApiUtils2(azkabanMonitorUrl, redisTemplate);
String exeIdsStr = azkabanApiUtils.stopFlow("jz_localflow_"+taskAlias+"_" + projectId, treeName);
baseBeanResponse.setCode(StatuConstant.SUCCESS_CODE);
baseBeanResponse.setMessage("停止成功");
baseBeanResponse.setData(exeIdsStr);
return baseBeanResponse;
}
/**
*SHELL/SQL版本发布
*/
@Override
public BaseResponse taskPublish(Long treeId, HttpServletRequest httpRequest) throws Exception {
BaseResponse baseResponse = new BaseResponse();
DmpDevelopTask dmpDevelopTask = dmpDevelopTaskDao.get(treeId);
// 修改人
dmpDevelopTask.setUpdateUserId(getHttpRequestUserId(httpRequest).toString());
// 修改时间
dmpDevelopTask.setUpdateTime(new Date());
//设置发布版本
dmpDevelopTask.setPublishVersion(dmpDevelopTask.getVersion());
dmpDevelopTaskDao.update(dmpDevelopTask);
baseResponse.setCode(StatuConstant.SUCCESS_CODE);
baseResponse.setMessage("发布成功");
return baseResponse;
}
/**
*软删除任务
*/
@Override
@Transactional(rollbackFor = Exception.class)
public BaseResponse softDeleteByTreeId(Integer treeId, HttpServletRequest httpRequest) throws Exception {
BaseResponse baseResponse = new BaseResponse();
DmpDevelopTask developTask = dmpDevelopTaskDao.get(treeId.longValue());
String taskType = developTask.getTaskType();
if (taskType.equals(CommConstant.TASK_TYPE_DEVELOP)) {
//取消发布的任务
BaseResponse baseResponseAzkaban = flowService.deleteAzkabanFlow(developTask);
if (baseResponseAzkaban.getCode().equals(StatuConstant.FAILURE_CODE)) {
throw new RuntimeException("azkaban取消发布任务失败");
}
}else if (taskType.equals(CommConstant.TASK_TYPE_DEVSHELL) || taskType.equals(CommConstant.TASK_TYPE_DEVSQL)) {
//什么也不做
}else {
baseResponse.setCode(StatuConstant.CODE_DATA_NOTMEET);
baseResponse.setMessage("任务类型不适合调用该方法");
return baseResponse;
}
//软删除树
DmpNavigationTree dmpNavigationTree = new DmpNavigationTree();
dmpNavigationTree.setId(treeId);
dmpNavigationTree.setDataStatus("0");
dmpNavigationTreeDao.update(dmpNavigationTree);
//软删除任务
developTask.setDataStatus("0");
dmpDevelopTaskDao.update(developTask);
baseResponse.setCode(StatuConstant.SUCCESS_CODE);
baseResponse.setMessage("软删除成功");
return baseResponse;
}
throw new RuntimeException("任务的任务类型为空!");
} else if (taskType.equals(CommConstant.TASK_TYPE_DEVSHELL)) {
taskAlias = "shell";
} else if (taskType.equals(CommConstant.TASK_TYPE_DEVSQL)) {
taskAlias = "sql";
} else {
throw new RuntimeException("该任务类型不能调用此方法停止,请检查任务类型!");
}
String azkabanMonitorUrl = dmpProjectConfigInfoDto.getDmpPublicConfigInfoDto().getAzkabanMonitorUrl();//AZKABAN WEB服务地址
AzkabanApiUtils2 azkabanApiUtils = new AzkabanApiUtils2(azkabanMonitorUrl, redisTemplate);
String exeIdsStr = azkabanApiUtils.stopFlow("jz_localflow_" + taskAlias + "_" + projectId, treeName);
baseBeanResponse.setCode(StatuConstant.SUCCESS_CODE);
baseBeanResponse.setMessage("停止成功");
baseBeanResponse.setData(exeIdsStr);
return baseBeanResponse;
}
/**
* SHELL/SQL版本发布
*/
@Override
public BaseResponse taskPublish(Long treeId, HttpServletRequest httpRequest) throws Exception {
BaseResponse baseResponse = new BaseResponse();
DmpDevelopTask dmpDevelopTask = dmpDevelopTaskDao.get(treeId);
// 修改人
dmpDevelopTask.setUpdateUserId(getHttpRequestUserId(httpRequest).toString());
// 修改时间
dmpDevelopTask.setUpdateTime(new Date());
//设置发布版本
dmpDevelopTask.setPublishVersion(dmpDevelopTask.getVersion());
dmpDevelopTaskDao.update(dmpDevelopTask);
baseResponse.setCode(StatuConstant.SUCCESS_CODE);
baseResponse.setMessage("发布成功");
return baseResponse;
}
/**
* 软删除任务
*/
@Override
@Transactional(rollbackFor = Exception.class)
public BaseResponse softDeleteByTreeId(Integer treeId, HttpServletRequest httpRequest) throws Exception {
BaseResponse baseResponse = new BaseResponse();
DmpDevelopTask developTask = dmpDevelopTaskDao.get(treeId.longValue());
String taskType = developTask.getTaskType();
if (taskType.equals(CommConstant.TASK_TYPE_DEVELOP)) {
//取消发布的任务
BaseResponse baseResponseAzkaban = flowService.deleteAzkabanFlow(developTask);
if (baseResponseAzkaban.getCode().equals(StatuConstant.FAILURE_CODE)) {
throw new RuntimeException("azkaban取消发布任务失败");
}
} else if (taskType.equals(CommConstant.TASK_TYPE_DEVSHELL) || taskType.equals(CommConstant.TASK_TYPE_DEVSQL)) {
//什么也不做
} else {
baseResponse.setCode(StatuConstant.CODE_DATA_NOTMEET);
baseResponse.setMessage("任务类型不适合调用该方法");
return baseResponse;
}
//软删除树
DmpNavigationTree dmpNavigationTree = new DmpNavigationTree();
dmpNavigationTree.setId(treeId);
dmpNavigationTree.setDataStatus("0");
dmpNavigationTreeDao.update(dmpNavigationTree);
//软删除任务
developTask.setDataStatus("0");
dmpDevelopTaskDao.update(developTask);
baseResponse.setCode(StatuConstant.SUCCESS_CODE);
baseResponse.setMessage("软删除成功");
return baseResponse;
}
/**
* 获取执行实例的日志详情
*
......@@ -1596,11 +1572,43 @@ public class DmpDevelopTaskServiceImpl extends BaseService implements DmpDevelop
@Override
public JsonResult queryExamplesLogByExecId(String execId) throws Exception {
List<Map> list = executionFlowsMapper.queryExamplesLogByExecId(execId);
if(list.size() > 0 && list != null) {
if (list.size() > 0 && list != null) {
list.forEach(map -> {
//map.put("log", map.get("log"));
});
}
return JsonResult.ok(list);
}
/**
* 运维大屏--获取任务状态
*
* @param projectId
* @return
* @author Bellamy
* @since 2021-02-22
*/
@Override
public JsonResult getTaskStatus(String projectId) throws Exception {
Map<String, Integer> taskStatus = new HashMap<>();
//RUNNING, FAILED,SUCCESS
//实时任务状态
Map<String, Object> realTimeTask = dmpRealtimeSyncInfoDao.queryTaskStatus(projectId);
Integer realTimeRunNum = Integer.valueOf(String.valueOf(realTimeTask.get("running")));
Integer realTimeFailedNum = Integer.valueOf(String.valueOf(realTimeTask.get("failed")));
//业务流程实例状态 :30-正在运行,50-运行成功,60-kill任务,70-运行失败
Map<String, Object> flowStatus = executionFlowsMapper.queryTaskInstanceStatus();
Integer flowRunNum = Integer.valueOf(String.valueOf(flowStatus.get("running")));
Integer flowSuccessNum = Integer.valueOf(String.valueOf(flowStatus.get("success")));
Integer flowFailedNum = Integer.valueOf(String.valueOf(flowStatus.get("failed")));
Integer flowManualNum = Integer.valueOf(String.valueOf(flowStatus.get("manualNum")));
taskStatus.put("running", realTimeRunNum + flowRunNum);
taskStatus.put("success", flowSuccessNum);
taskStatus.put("failed", realTimeFailedNum + flowFailedNum);
taskStatus.put("manual", flowManualNum);
return JsonResult.ok(taskStatus);
}
}
\ No newline at end of file
......@@ -41,29 +41,12 @@ public class DmpOrgMangeServiceImpl implements DmpOrgMangeService {
*/
@Override
public JsonResult queryOrgListPage(OrganizationManageListQueryReq req) throws Exception {
JsonResult result = new JsonResult();
String url = gatewayUrl + GatewayApiConstant.orgListPage;
if (StringUtils.isNotEmpty(req.getOrgName())) {
req.setOrgName(req.getOrgName().trim());
}
String resultData = HttpClientUtils.post(url, JSONObject.toJSONString(req));
if (StringUtils.isEmpty(resultData)) {
throw new RuntimeException("查询失败!");
}
logger.info("#################组织管理列数据{}" + resultData);
Map jsonObject = JSONObject.parseObject(resultData);
if (jsonObject.containsKey("code")) {
if ("200".equals(jsonObject.get("code").toString())) {
return JsonResult.ok(jsonObject.get("data"));
}
}
if (jsonObject.containsKey("msg")) {
logger.info(jsonObject.get("msg").toString());
result.setMessage(jsonObject.get("msg").toString());
result.setCode(ResultCode.INTERNAL_SERVER_ERROR);
}
JsonResult result = GatewayApiConstant.postRequest2GetData(url, JSONObject.toJSONString(req));
return result;
}
......@@ -79,18 +62,8 @@ public class DmpOrgMangeServiceImpl implements DmpOrgMangeService {
Map params = new HashMap();
params.put("id", id);
String url = gatewayUrl + GatewayApiConstant.delOrg;
String returnData = HttpClientUtils.getJsonForParam(url, params);
if (StringUtils.isEmpty(returnData)) {
throw new RuntimeException("删除失败!");
}
logger.info("#################响应结果{}" + returnData);
Map map = JSONObject.parseObject(returnData);
if (map.containsKey("code")) {
if ("200".equals(map.get("code").toString())) {
return JsonResult.ok();
}
}
return JsonResult.error("删除失败!");
JsonResult result = GatewayApiConstant.getRequest2GetData(url, params);
return result;
}
/**
......@@ -102,26 +75,9 @@ public class DmpOrgMangeServiceImpl implements DmpOrgMangeService {
*/
@Override
public JsonResult addOrg(OrganizationManageAddReq req) throws Exception {
JsonResult result = new JsonResult();
String url = gatewayUrl + GatewayApiConstant.addOrg;
req.setCreateUser(SessionUtils.getCurrentUserName());
String returnData = HttpClientUtils.post(url, JSONObject.toJSONString(req));
if (StringUtils.isEmpty(returnData)) {
throw new RuntimeException("新增失败!");
}
logger.info("#################响应结果{}" + returnData);
Map map = JSONObject.parseObject(returnData);
if (map.containsKey("code")) {
if ("200".equals(map.get("code").toString())) {
return JsonResult.ok();
}
}
if (map.containsKey("msg")) {
logger.info(map.get("msg").toString());
result.setMessage(map.get("msg").toString());
result.setCode(ResultCode.INTERNAL_SERVER_ERROR);
}
JsonResult result = GatewayApiConstant.postRequest2GetData(url, JSONObject.toJSONString(req));
return result;
}
......@@ -134,27 +90,10 @@ public class DmpOrgMangeServiceImpl implements DmpOrgMangeService {
*/
@Override
public JsonResult updateOrg(OrganizationManageUpdateReq req) throws Exception {
JsonResult result = new JsonResult();
String url = gatewayUrl + GatewayApiConstant.addOrg;
req.setCreateUser(SessionUtils.getCurrentUserName());
String returnData = HttpClientUtils.post(url, JSONObject.toJSONString(req));
if (StringUtils.isEmpty(returnData)) {
throw new RuntimeException("编辑失败!");
}
logger.info("#################响应结果{}" + returnData);
Map map = JSONObject.parseObject(returnData);
if (map.containsKey("code")) {
if ("200".equals(map.get("code").toString())) {
return JsonResult.ok();
}
}
if (map.containsKey("msg")) {
logger.info(map.get("msg").toString());
result.setMessage(map.get("msg").toString());
result.setCode(ResultCode.INTERNAL_SERVER_ERROR);
}
JsonResult result = GatewayApiConstant.postRequest2GetData(url, JSONObject.toJSONString(req));
return result;
}
......@@ -166,27 +105,10 @@ public class DmpOrgMangeServiceImpl implements DmpOrgMangeService {
*/
@Override
public JsonResult getOrgInfoByOrgId(String id) throws Exception {
JsonResult result = new JsonResult();
String url = gatewayUrl + GatewayApiConstant.orgDetail;
OrganizationManageDetailQueryReq req = new OrganizationManageDetailQueryReq();
req.setId(Long.valueOf(id));
String returnData = HttpClientUtils.post(url, JSONObject.toJSONString(req));
if (StringUtils.isEmpty(returnData)) {
throw new RuntimeException("查询失败!");
}
logger.info("#################响应结果{}" + returnData);
Map map = JSONObject.parseObject(returnData);
if (map.containsKey("code")) {
if ("200".equals(map.get("code").toString())) {
return JsonResult.ok(map.get("data"));
}
}
if (map.containsKey("msg")) {
logger.info(map.get("msg").toString());
result.setMessage(map.get("msg").toString());
result.setCode(ResultCode.INTERNAL_SERVER_ERROR);
}
JsonResult result = GatewayApiConstant.postRequest2GetData(url, JSONObject.toJSONString(req));
return result;
}
}
......@@ -2,6 +2,7 @@ package com.jz.dmp.modules.service.impl;
import com.alibaba.fastjson.JSONObject;
import com.amazonaws.services.dynamodbv2.xspec.M;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.jz.agent.service.DmpDsAgentService;
......@@ -347,7 +348,6 @@ public class DmpRealtimeSyncInfoServiceImpl implements DmpRealtimeSyncInfoServic
Integer srcDataSourceId = sourceDbInfo.getId();
Integer targetDataSourceId = targetDbInfo.getId();
logger.info("###################开始--同步数据源到数据源任务################### ");
Long realtiemId = null; //同步任务id
//源数据源到数据源同步connector信息
//解析黑名单表
......@@ -423,10 +423,21 @@ public class DmpRealtimeSyncInfoServiceImpl implements DmpRealtimeSyncInfoServic
DmpRealtimeTaskHistory taskHistory = new DmpRealtimeTaskHistory();
BeanUtils.copyProperties(saveBody, taskHistory);
if (StringUtils.isEmpty(String.valueOf(params.get("taskId")))) {
Map<String, String> respData = publishTask2Kafka(connectorUrl, jsonStr);
Map<String, String> respData = publishTask2Kafka(connectorUrl, jsonStr, "");
saveBody.setConnectorJobId(respData.get("connectorJobId"));
saveBody.setStatus(respData.get("status"));
dmpRealtimeSyncInfoDao.insert(saveBody);
//异步获取任务状态
Thread thread = new Thread(new Runnable() {
@Override
public void run() {
Map map = new HashMap();
map.put("id", saveBody.getId());
getKafkaTaskStatus(connectorUrl + respData.get("connectorJobId") + "/status", map);
}
});
thread.start();
} else {
DmpRealtimeSyncInfo realtimeTask = dmpRealtimeSyncInfoDao.queryById(Integer.valueOf(params.get("taskId").toString()));
if (realtimeTask == null)
......@@ -436,7 +447,7 @@ public class DmpRealtimeSyncInfoServiceImpl implements DmpRealtimeSyncInfoServic
//编辑时,先删除任务,再发布任务
HttpClientUtils.httpDelete(connectorUrl + "/" + realtimeTask.getConnectorJobId() + "/");
Map<String, String> respData = publishTask2Kafka(connectorUrl, jsonStr);
Map<String, String> respData = publishTask2Kafka(connectorUrl, jsonStr, params.get("taskId").toString());
saveBody.setConnectorJobId(respData.get("connectorJobId"));
saveBody.setStatus(respData.get("status"));
saveBody.setUpdateTime(new Date());
......@@ -449,7 +460,7 @@ public class DmpRealtimeSyncInfoServiceImpl implements DmpRealtimeSyncInfoServic
version = version.add(new BigDecimal(1.0));
taskHistory.setVersion(String.valueOf(version));
}
logger.info("###################保存实时同步任务--结束 ################");
logger.info("################### save task end ################");
taskHistory.setRealtimeSyncId(saveBody.getId());