Commit e34416ca authored by mcb's avatar mcb

任务状态查看

parent a6f92fb6
......@@ -247,6 +247,11 @@
<artifactId>commons-fileupload</artifactId>
<version>1.3.1</version>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>4.5.3</version><!--$NO-MVN-MAN-VER$-->
</dependency>
</dependencies>
<build>
......
......@@ -16,25 +16,27 @@ public enum ResultCode {
/** 参数错误 */
PARAMS_ERROR("403", "参数错误 "),
OPERATION_DATA_NO_EXIST("410","操作数据不存在"),
PARAMS_ERROR_TOKEN("446", "token无效"),
/** 不支持当前请求方? */
METHOD_NOT_ALLOWED("405", "不支持当前请求方? "),
/** 不支持当前请求方? */
METHOD_NOT_ALLOWED("405", "不支持当前请求方? "),
/** 不支持或已经废弃 */
NOT_SUPPORTED("410", "不支持或已经废弃"),
/** 不支持当前媒体类? */
UNSUPPORTED_MEDIA_TYPE("415", "不支持当前媒体类?"),
/** 不支持当前媒体类? */
UNSUPPORTED_MEDIA_TYPE("415", "不支持当前媒体类?"),
/** AuthCode错误 */
INVALID_AUTHCODE("444", "无权限访?"),
INVALID_AUTHCODE("444", "无权限访?"),
/** 太频繁的调用 */
TOO_FREQUENT("445", "太频繁的调用"),
/** 未知的错? */
/** 未知的错? */
UNKNOWN_ERROR("499", "未知错误"),
/** 内部服务出错 */
......
......@@ -4,6 +4,7 @@ package com.jz.common.utils;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.google.gson.Gson;
import com.jz.common.utils.web.HttpClientUtils;
import com.jz.common.utils.web.SessionUtils;
import com.jz.dmp.modules.controller.DataIntegration.bean.flow.FlowExecution;
import com.jz.dmp.modules.controller.DataIntegration.bean.flow.FlowPro;
......@@ -627,54 +628,54 @@ public class AzkabanApiUtils2 {
* @return List<FlowExecution> 返回类型
* @throws
*/
// public List<FlowExecution> getSyncingFlowExecution(Long projectId, String flow, Integer start, Integer length) {
//
// List<FlowExecution> list = new ArrayList<FlowExecution>();
//
// //登录
// String sessionId = login();
//
// String executeFlowUrl = azkabanServerUrl + "/manager?token=" + sessionId;
// Map<String, Object> paramMap = new HashMap<String, Object>();
// paramMap.put("session.id", sessionId);
// paramMap.put("ajax", "fetchFlowExecutions");
// paramMap.put("project", "jz_localflow_"+projectId);
// paramMap.put("flow", flow);
// paramMap.put("start", start);
// paramMap.put("length", length);
//
// JSONObject getForObject = null;
// try {
// //postForObject = bulidRestTemplate().postForObject(executeFlowUrl, linkedMultiValueMap, Map.class);
// //String getForObjectStr = bulidRestTemplate().getForObject(executeFlowUrl, String.class, paramMap);
// String getForObjectStr = HttpClientUtils.getJsonForParam(executeFlowUrl, paramMap);
// getForObject = JSON.parseObject(getForObjectStr);
// } catch (Exception e) {
// LOGGER.error(executeFlowUrl + "----" + paramMap + "----获取同步状态结果接口异常");
// e.printStackTrace();
// throw new RuntimeException("获取同步状态结果接口异常");
// }
//
// if (getForObject==null) {
// return list;
// }
//
// if (getForObject.containsKey("error")){
// throw new RuntimeException(getForObject.get("error").toString());
// }
// String status = (String) getForObject.get("status");
// if ("error".equals(status)) {
// String message = (String) getForObject.get("message");
// throw new RuntimeException(message);
// }
//
// String executions = getForObject.getString("executions");
//
// LOGGER.info("获取同步状态结果成功:"+executions);
//
// list = JSONObject.parseArray(executions, FlowExecution.class);
//
// return list;
// }
public List<FlowExecution> getSyncingFlowExecution(Long projectId, String flow, Integer start, Integer length) {
List<FlowExecution> list = new ArrayList<FlowExecution>();
//登录
String sessionId = login();
String executeFlowUrl = azkabanServerUrl + "/manager?token=" + sessionId;
Map<String, Object> paramMap = new HashMap<String, Object>();
paramMap.put("session.id", sessionId);
paramMap.put("ajax", "fetchFlowExecutions");
paramMap.put("project", "jz_localflow_"+projectId);
paramMap.put("flow", flow);
paramMap.put("start", start);
paramMap.put("length", length);
JSONObject getForObject = null;
try {
//postForObject = bulidRestTemplate().postForObject(executeFlowUrl, linkedMultiValueMap, Map.class);
//String getForObjectStr = bulidRestTemplate().getForObject(executeFlowUrl, String.class, paramMap);
String getForObjectStr = HttpClientUtils.getJsonForParam(executeFlowUrl, paramMap);
getForObject = JSON.parseObject(getForObjectStr);
} catch (Exception e) {
LOGGER.error(executeFlowUrl + "----" + paramMap + "----获取同步状态结果接口异常");
e.printStackTrace();
throw new RuntimeException("获取同步状态结果接口异常");
}
if (getForObject==null) {
return list;
}
if (getForObject.containsKey("error")){
throw new RuntimeException(getForObject.get("error").toString());
}
String status = (String) getForObject.get("status");
if ("error".equals(status)) {
String message = (String) getForObject.get("message");
throw new RuntimeException(message);
}
String executions = getForObject.getString("executions");
LOGGER.info("获取同步状态结果成功:"+executions);
list = JSONObject.parseArray(executions, FlowExecution.class);
return list;
}
}
package com.jz.common.utils.web;
import com.alibaba.fastjson.JSONObject;
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.NameValuePair;
import org.apache.http.ParseException;
import org.apache.http.client.ClientProtocolException;
import org.apache.http.client.config.RequestConfig;
import org.apache.http.client.entity.UrlEncodedFormEntity;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.conn.ssl.SSLConnectionSocketFactory;
import org.apache.http.conn.ssl.SSLContexts;
import org.apache.http.conn.ssl.TrustSelfSignedStrategy;
import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.message.BasicHeader;
import org.apache.http.message.BasicNameValuePair;
import org.apache.http.protocol.HTTP;
import org.apache.http.util.EntityUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import javax.net.ssl.SSLContext;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
import java.security.KeyManagementException;
import java.security.KeyStore;
import java.security.KeyStoreException;
import java.security.NoSuchAlgorithmException;
import java.security.cert.CertificateException;
import java.util.*;
import java.util.Map.Entry;
/**
*
* @author hack2003
* @date 2016-10-18
* @version v1.0
*
*/
public class HttpClientUtils {
private static final Logger LOGGER = LoggerFactory.getLogger(HttpClientUtils.class);
/**
* HttpClient连接SSL
*/
public void ssl() {
CloseableHttpClient httpclient = null;
try {
KeyStore trustStore = KeyStore.getInstance(KeyStore
.getDefaultType());
FileInputStream instream = new FileInputStream(new File(
"d:\\tomcat.keystore"));
try {
// 加载keyStore d:\\tomcat.keystore
trustStore.load(instream, "123456".toCharArray());
} catch (CertificateException e) {
e.printStackTrace();
} finally {
try {
instream.close();
} catch (Exception ignore) {
}
}
// 相信自己的CA和所有自签名的证书
SSLContext sslcontext = SSLContexts
.custom()
.loadTrustMaterial(trustStore,
new TrustSelfSignedStrategy()).build();
// 只允许使用TLSv1协议
SSLConnectionSocketFactory sslsf = new SSLConnectionSocketFactory(
sslcontext,
new String[] { "TLSv1" },
null,
SSLConnectionSocketFactory.BROWSER_COMPATIBLE_HOSTNAME_VERIFIER);
httpclient = HttpClients.custom().setSSLSocketFactory(sslsf)
.build();
// 创建http请求(get方式)
HttpGet httpget = new HttpGet(
"https://localhost:8443/myDemo/Ajax/serivceJ.action");
System.out.println("executing request" + httpget.getRequestLine());
CloseableHttpResponse response = httpclient.execute(httpget);
try {
HttpEntity entity = response.getEntity();
System.out.println("----------------------------------------");
System.out.println(response.getStatusLine());
if (entity != null) {
System.out.println("Response content length: "
+ entity.getContentLength());
System.out.println(EntityUtils.toString(entity));
EntityUtils.consume(entity);
}
} finally {
response.close();
}
} catch (ParseException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
} catch (KeyManagementException e) {
e.printStackTrace();
} catch (NoSuchAlgorithmException e) {
e.printStackTrace();
} catch (KeyStoreException e) {
e.printStackTrace();
} finally {
if (httpclient != null) {
try {
httpclient.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
}
/**
* @discription:
* @param url 访问地址
* @param token 请求头中存放token
* @param json 请求数据体
* @return
* @date: 2019年10月25日
*/
public static String postJsonData(String url, String token, String json){
LOGGER.info("===================postJsonData start=======================");
LOGGER.info("url:"+url);
LOGGER.info("token:"+token);
LOGGER.info("json:"+json);
String charset="UTF-8";
CloseableHttpClient httpClient = null;
HttpPost httpPost = null;
String result = null;
try
{
httpClient = HttpClients.createDefault();
httpPost = new HttpPost(url);
RequestConfig requestConfig = RequestConfig.custom().setSocketTimeout(50000).setConnectTimeout(50000).build();//设置请求和传输超时时间
httpPost.setConfig(requestConfig);
httpPost.setHeader("token", token);
StringEntity se = new StringEntity(json,"UTF-8");
se.setContentType("application/json");
se.setContentEncoding(new BasicHeader(HTTP.CONTENT_TYPE, "application/json"));
httpPost.setEntity(se);
LOGGER.info("请求开始时间:"+System.currentTimeMillis());
HttpResponse response = httpClient.execute(httpPost);
LOGGER.info("请求结束时间:"+System.currentTimeMillis());
if(response != null)
{
HttpEntity resEntity = response.getEntity();
if(resEntity != null)
{
result = EntityUtils.toString(resEntity,charset);
}
}
}catch(Exception ex)
{
LOGGER.info("异常捕捉请求结束时间:"+System.currentTimeMillis());
ex.printStackTrace();
LOGGER.info(ex.getMessage());
}
LOGGER.info("===================postJsonData end=======================");
return result;
}
/**
* post方式提交表单(模拟用户登录请求)
*/
public void postForm() {
// 创建默认的httpClient实例.
CloseableHttpClient httpclient = HttpClients.createDefault();
// 创建httppost
HttpPost httppost = new HttpPost(
"http://localhost:8080/myDemo/Ajax/serivceJ.action");
// 创建参数队列
List<NameValuePair> formparams = new ArrayList<NameValuePair>();
formparams.add(new BasicNameValuePair("username", "admin"));
formparams.add(new BasicNameValuePair("password", "123456"));
UrlEncodedFormEntity uefEntity;
try {
uefEntity = new UrlEncodedFormEntity(formparams, "UTF-8");
httppost.setEntity(uefEntity);
System.out.println("executing request " + httppost.getURI());
CloseableHttpResponse response = httpclient.execute(httppost);
try {
if (response.getStatusLine().getStatusCode() == 200) {
HttpEntity httpEntity = response.getEntity();
if (httpEntity != null) {
System.out
.println("--------------------------------------");
System.out.println("Response content: "
+ EntityUtils.toString(httpEntity, "UTF-8"));
System.out
.println("--------------------------------------");
}
} else {
httppost.abort();
}
} finally {
response.close();
}
} catch (ClientProtocolException e) {
e.printStackTrace();
} catch (UnsupportedEncodingException e1) {
e1.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
} finally {
// 关闭连接,释放资源
if (httpclient != null) {
try {
httpclient.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
}
/**
* 发送 get请求
*/
public static void get() {
CloseableHttpClient httpclient = HttpClients.createDefault();
try {
// 创建httpget.
HttpGet httpget = new HttpGet("http://www.baidu.com/");
System.out.println("executing request " + httpget.getURI());
// 执行get请求.
CloseableHttpResponse response = httpclient.execute(httpget);
try {
// 获取响应实体
HttpEntity entity = response.getEntity();
System.out.println("--------------------------------------");
// 打印响应状态
System.out.println(response.getStatusLine());
if (entity != null) {
// 打印响应内容长度
System.out.println("Response content length: "
+ entity.getContentLength());
// 打印响应内容
System.out.println("Response content: "
+ EntityUtils.toString(entity));
}
System.out.println("------------------------------------");
} finally {
response.close();
}
} catch (ClientProtocolException e) {
e.printStackTrace();
} catch (ParseException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
} finally {
// 关闭连接,释放资源
try {
httpclient.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
/**
* 发送 post请求访问本地应用并根据传递参数不同返回不同结果
* @return
*
* @throws IOException
* @throws ClientProtocolException
*/
public static String post(String url,String json)
{
String charset="UTF-8";
CloseableHttpClient httpClient = null;
HttpPost httpPost = null;
String result = null;
try
{
httpClient = HttpClients.createDefault();
httpPost = new HttpPost(url);
RequestConfig requestConfig = RequestConfig.custom().setSocketTimeout(50000).setConnectTimeout(50000).build();//设置请求和传输超时时间
httpPost.setConfig(requestConfig);
StringEntity se = new StringEntity(json,"UTF-8");
se.setContentType("application/json");
se.setContentEncoding(new BasicHeader(HTTP.CONTENT_TYPE, "application/json"));
System.out.println("-------------"+ JSONObject.toJSONString(se));
httpPost.setEntity(se);
HttpResponse response = httpClient.execute(httpPost);
if(response != null)
{
HttpEntity resEntity = response.getEntity();
if(resEntity != null)
{
result = EntityUtils.toString(resEntity,charset);
}
}
}catch(Exception ex)
{
ex.printStackTrace();
}
return result;
}
/**
* 带参
* @param url
* @param paramName
* @param json
* @return
*/
public static String post(String url,String paramName,String json)
{
String charset="UTF-8";
CloseableHttpClient httpClient = null;
HttpPost httpPost = null;
String result = null;
try
{
httpClient = HttpClients.createDefault();
httpPost = new HttpPost(url);
RequestConfig requestConfig = RequestConfig.custom().setSocketTimeout(3000).setConnectTimeout(3000).build();//设置请求和传输超时时间
httpPost.setConfig(requestConfig);
List<NameValuePair> list = new LinkedList<>();
BasicNameValuePair param1 = new BasicNameValuePair(paramName, json);
list.add(param1);
// StringEntity se = new StringEntity(json,"UTF-8");
// se.setContentType("application/json");
// se.setContentEncoding(new BasicHeader(HTTP.CONTENT_TYPE, "application/json"));
UrlEncodedFormEntity entityParam = new UrlEncodedFormEntity(list, "UTF-8");
// entityParam.setContentType("application/json");
// entityParam.setContentEncoding(new BasicHeader(HTTP.CONTENT_TYPE, "application/json"));
httpPost.setEntity(entityParam);
HttpResponse response = httpClient.execute(httpPost);
if(response != null)
{
HttpEntity resEntity = response.getEntity();
if(resEntity != null)
{
result = EntityUtils.toString(resEntity,charset);
}
}
}catch(Exception ex)
{
ex.printStackTrace();
}
return result;
}
/**
* 提交JSON参数
* @param url
* @param paramName
* @param json
* @return
*/
public static String postJson(String url,String paramName,String json)
{
String charset="UTF-8";
CloseableHttpClient httpClient = null;
HttpPost httpPost = null;
String result = null;
try
{
httpClient = HttpClients.createDefault();
httpPost = new HttpPost(url);
RequestConfig requestConfig = RequestConfig.custom().setSocketTimeout(3000).setConnectTimeout(3000).build();//设置请求和传输超时时间
httpPost.setConfig(requestConfig);
StringEntity se = new StringEntity(json,"UTF-8");
se.setContentType("application/json");
se.setContentEncoding(new BasicHeader(HTTP.CONTENT_TYPE, "application/json"));
httpPost.setEntity(se);
HttpResponse response = httpClient.execute(httpPost);
if(response != null)
{
HttpEntity resEntity = response.getEntity();
if(resEntity != null)
{
result = EntityUtils.toString(resEntity,charset);
}
}
}catch(Exception ex)
{
ex.printStackTrace();
}
return result;
}
public static String dopost(String url, String json) throws ClientProtocolException,IOException {
String result=null;
String APPLICATION_JSON = "application/json";
String charset="UTF-8";
// 将JSON进行UTF-8编码,以便传输中文
String encoderJson = URLEncoder.encode(json, charset);
CloseableHttpClient httpclient = HttpClients.createDefault();
HttpPost httppost = new HttpPost(url);
httppost.addHeader(HTTP.CONTENT_TYPE, APPLICATION_JSON);
StringEntity stringEntity = new StringEntity(encoderJson);
stringEntity.setContentType("text/json");
stringEntity.setContentEncoding(new BasicHeader(HTTP.CONTENT_TYPE,APPLICATION_JSON));
httppost.setEntity(stringEntity);
//System.out.println("executing request " + httppost.getURI());
CloseableHttpResponse response = httpclient.execute(httppost);
if (response.getStatusLine().getStatusCode() == 200) {
HttpEntity httpEntity = response.getEntity();
if (httpEntity != null) {
System.out.println("Response content: "+ EntityUtils.toString(httpEntity, charset));
result = EntityUtils.toString(httpEntity,charset);
}
} else {
httppost.abort();
}
response.close();
if (httpclient != null) {
try {
httpclient.close();
} catch (IOException e) {
e.printStackTrace();
}
}
return result;
}
/**http请求资源,json不编码
* @param url
* @param json
* @return
* @throws ClientProtocolException
* @throws IOException
*/
public static String dopostNoEncode(String url, String json) throws ClientProtocolException,IOException {
String result=null;
String APPLICATION_JSON = "application/json";
String charset="UTF-8";
// 将JSON进行UTF-8编码,以便传输中文
CloseableHttpClient httpclient = HttpClients.createDefault();
HttpPost httppost = new HttpPost(url);
httppost.addHeader(HTTP.CONTENT_TYPE, APPLICATION_JSON);
StringEntity stringEntity = new StringEntity(json, charset);
stringEntity.setContentType("text/json");
stringEntity.setContentEncoding(new BasicHeader(HTTP.CONTENT_TYPE,APPLICATION_JSON));
httppost.setEntity(stringEntity);
//System.out.println("executing request " + httppost.getURI());
CloseableHttpResponse response = httpclient.execute(httppost);
if (response.getStatusLine().getStatusCode() == 200) {
HttpEntity httpEntity = response.getEntity();
if (httpEntity != null) {
//System.out.println("Response content: "+ EntityUtils.toString(httpEntity, charset));
result = EntityUtils.toString(httpEntity,charset);
}
} else {
httppost.abort();
}
response.close();
if (httpclient != null) {
try {
httpclient.close();
} catch (IOException e) {
e.printStackTrace();
}
}
return result;
}
/**
* 发送 post请求访问本地应用并根据传递参数不同返回不同结果
* @return
*
* @throws IOException
* @throws ClientProtocolException
*/
public static String postJson(String url, com.alibaba.fastjson.JSONObject json)
{
String charset="UTF-8";
CloseableHttpClient httpClient = null;
HttpPost httpPost = null;
String result = null;
try
{
httpClient = HttpClients.createDefault();
httpPost = new HttpPost(url);
RequestConfig requestConfig = RequestConfig.custom().setSocketTimeout(10000).setConnectTimeout(10000).build();//设置请求和传输超时时间
httpPost.setConfig(requestConfig);
StringEntity se = new StringEntity(json.toString(), "UTF-8");
se.setContentType("application/json");
se.setContentEncoding(new BasicHeader(HTTP.CONTENT_TYPE, "application/json"));
httpPost.setEntity(se);
HttpResponse response = httpClient.execute(httpPost);
if(response != null)
{
HttpEntity resEntity = response.getEntity();
if(resEntity != null)
{
result = EntityUtils.toString(resEntity,charset);
}
}
}catch(Exception ex)
{
ex.printStackTrace();
}
return result;
}
/**
* get请求,返回字节数组
*
* @param url
* @param params
* @param headers
* @return
* @throws IOException
* @throws ClientProtocolException
*/
public static byte[] doGetByByte(String url, Map<String, String> params, Map<String, String> headers) throws IOException {
LOGGER.info("===================doGetByByte start =======================");
// 参数
StringBuilder paramsBuilder = new StringBuilder(url);
byte[] responseContent = null;
if (params != null && !params.keySet().isEmpty()) {
if (url.indexOf("?") == -1) {
paramsBuilder.append("?");
}
List<NameValuePair> list = new ArrayList<>();
Set<String> keySet = params.keySet();
Iterator<String> iterator = keySet.iterator();
while (iterator.hasNext()) {
String key = iterator.next();
String value = params.get(key);
list.add(new BasicNameValuePair(key, value));
}
String paramsStr = EntityUtils.toString(new UrlEncodedFormEntity(list));
paramsBuilder.append(paramsStr);
}
HttpGet httpGet = new HttpGet(paramsBuilder.toString());
// 头
if (headers != null && !headers.keySet().isEmpty()) {
Set<String> keySet = headers.keySet();
Iterator<String> iterator = keySet.iterator();
while (iterator.hasNext()) {
String key = iterator.next();
String value = headers.get(key);
httpGet.addHeader(key, value);
}
}
try {
CloseableHttpClient httpClient = HttpClients.createDefault();
CloseableHttpResponse response = httpClient.execute(httpGet);
HttpEntity resEntity=null;
if (response.getStatusLine().getStatusCode() == 200) { // 请求成功状态
resEntity = response.getEntity();
}
if(resEntity != null){
responseContent = EntityUtils.toByteArray(resEntity);
// result = EntityUtils.toString(resEntity,charset);
}
} catch (Exception e) {
LOGGER.info("异常捕捉请求结束时间:"+System.currentTimeMillis());
e.printStackTrace();
LOGGER.info(e.getMessage());
}
LOGGER.info("===================doGetByByte end=======================");
return responseContent;
}
/**
* @discription:
* @param url 访问地址
* @param token 请求头中存放token
* @param json 请求数据体
* @return
* @date: 2019年10月25日
*/
public static byte[] postJsonDataByByte(String url, String token, String json){
LOGGER.info("===================postJsonDataByByte start=======================");
LOGGER.info("url:"+url);
LOGGER.info("token:"+token);
LOGGER.info("json:"+json);
String charset="UTF-8";
CloseableHttpClient httpClient = null;
HttpPost httpPost = null;
String result = null;
byte[] responseContent = null;
try
{
httpClient = HttpClients.createDefault();
httpPost = new HttpPost(url);
RequestConfig requestConfig = RequestConfig.custom().setSocketTimeout(50000).setConnectTimeout(50000).build();//设置请求和传输超时时间
httpPost.setConfig(requestConfig);
httpPost.setHeader("token", token);
StringEntity se = new StringEntity(json,"UTF-8");
se.setContentType("application/json");
se.setContentEncoding(new BasicHeader(HTTP.CONTENT_TYPE, "application/json"));
httpPost.setEntity(se);
LOGGER.info("请求开始时间:"+System.currentTimeMillis());
HttpResponse response = httpClient.execute(httpPost);
LOGGER.info("请求结束时间:"+System.currentTimeMillis());
if(response != null){
HttpEntity resEntity = response.getEntity();
if(response.getStatusLine().getStatusCode() == 200) {
if(resEntity != null){
responseContent = EntityUtils.toByteArray(resEntity);
}
}else {
LOGGER.info("请求失败:"+EntityUtils.toString(resEntity,charset));
return responseContent;
}
}
}catch(Exception ex){
LOGGER.info("异常捕捉请求结束时间:"+System.currentTimeMillis());
ex.printStackTrace();
LOGGER.info(ex.getMessage());
}
LOGGER.info("===================postJsonDataByByte end=======================");
return responseContent;
}
/**
* 发送 getJsonForParam请求
*/
public static String getJsonForParam(String url, Map<String, Object> paramMap) {
LOGGER.info("===================getJsonForParam start=======================");
LOGGER.info("url:" + url);
LOGGER.info("json:" + paramMap);
String result = null;
StringBuilder sb = new StringBuilder();
for (Entry<String, Object> entry : paramMap.entrySet()) {
sb.append("&");
sb.append(entry.getKey());
sb.append("=");
sb.append(entry.getValue());
}
String requestUrl = url+sb.toString();
CloseableHttpClient httpclient = HttpClients.createDefault();
try {
// 创建httpget.
HttpGet httpget = new HttpGet(requestUrl);
System.out.println("executing request " + httpget.getURI());
// 执行get请求.
CloseableHttpResponse response = httpclient.execute(httpget);
// 获取响应实体
HttpEntity entity = response.getEntity();
System.out.println("--------------------------------------");
// 打印响应状态
System.out.println(response.getStatusLine());
if (entity != null) {
result = EntityUtils.toString(entity);
LOGGER.info(result);
}
} catch (ClientProtocolException e) {
e.printStackTrace();
} catch (ParseException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
LOGGER.info("===================getJsonForParam end=======================");
return result;
}
public static void main(String[] args) throws Exception {
// 私钥
/*String privateKey = "MIICdgIBADANBgkqhkiG9w0BAQEFAASCAmAwggJcAgEAAoGBAJzAfk55exxmvy3+pXsJINZEtmwUp6eBfDSl2YnT5bdJL3nzPnSjmaWsf8x9hR4QyGnvlV/Vo0sk36X7ATcqxfIn0+6W5f8IR4XtVDhxZsD/cK8nVThqFGQagmyNAwxP/wBnAXOy+fpwZrMOgqfosYmVsmImFWbHA87C4mx0bwoJAgMBAAECgYB4tlBOVIT3ITTW0cRT1HrCJxYoc1uMxk2FKbc1ycWceTKjgiu1nQtEp2ufaYYq2hfMZOEudRIUWygT5RFRj5HxLfL6Me3y6dtgyHvOVeMDNGAG+tsn8ObQCQjZ/hVKzFFgHlrHv5i4zX44im2IdvLqnV6cEUneduJfZAQT/XTGUQJBANAZbuTqlDRj/9ObGZEvaPe95FGAPNFEiNmRvLsCsRmruJA5h2ogwx8O4Yll5LylKV6C33Vws4pgAPBHvOzGTx0CQQDA1VYU4ihNyvMknFIAmMT2ojQmQ8ASX64hVFWY9ehf5JaJ+ZD1c1BvbrmubpIo7pPci50BmXnjq6EcxVML/VbdAkAwEH/FjczXYPV4yY0ZNIsZFZoDnQvvBdZZ8khWJWQEWt5RKYh2YcTPip9bHda8H6Wzd6TnOjWt00jENr2TLqadAkEAq0TQD/xOj8mR6xJsQtttFSE78EB8d9VDc5bT7+d5XLJKgoGGnnqtFkvh32uVpYVBDsFx0dneyLfHgSZBfISmgQJADZ71qrfCDvuoYNS4aOW52OL6LMC84Qi2EnZzl5OHkUuOv5jwBoOCRLEn0N999EMP6DBg8P5kg1llTq7bMG11ug==";
RequestCSVFileParamBean bean = new RequestCSVFileParamBean();
bean.setGetFile("1.csv");
bean.setSign(RSA2.sign(bean.getGetFile().getBytes(), privateKey));
bean.setSourceID("ccc");
bean.setTimeStamp(System.currentTimeMillis() / 1000 + "");
HttpClientUtils http = new HttpClientUtils();
String url = "http://127.0.0.1:8080/mysales_interface/getExtCsvFile";
http.post(url,JSON.toJSONString(bean));*/
}
}
......@@ -3,9 +3,7 @@ package com.jz.dmp.modules.controller.DataIntegration;
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.SourceDbNameListDto;
import com.jz.dmp.modules.controller.DataIntegration.bean.TaskListPageDto;
import com.jz.dmp.modules.controller.DataIntegration.bean.TaskListPageReq;
import com.jz.dmp.modules.controller.DataIntegration.bean.*;
import com.jz.dmp.modules.service.OfflineSynchService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
......@@ -73,8 +71,8 @@ public class OfflineSynchController {
@ApiOperation(value = "根据源数据库id,获取源数据表-下拉框", notes = "根据源数据库id,获取源数据表")
@GetMapping(value = "/sourceTableList")
@ApiImplicitParam(name = "sourceDbId", value = "源数据库id")
public JsonResult getSourceTableList(@RequestParam Integer sourceDbId,@RequestParam(value = "targetName", required = false) String targetName) throws Exception {
JsonResult list = offlineSynchService.querygSourceTableList(sourceDbId,targetName);
public JsonResult getSourceTableList(@RequestParam Integer sourceDbId, @RequestParam(value = "targetName", required = false) String targetName) throws Exception {
JsonResult list = offlineSynchService.querygSourceTableList(sourceDbId, targetName);
return list;
}
......@@ -87,10 +85,38 @@ public class OfflineSynchController {
@GetMapping(value = "/taskRunNowByTaskId")
@ApiImplicitParam(name = "taskId", value = "任务id")
public JsonResult getTaskRunNowByTaskId(@RequestParam(value = "taskId") String taskId) throws Exception {
if(StringUtils.isEmpty(taskId)){
if (StringUtils.isEmpty(taskId)) {
return new JsonResult(ResultCode.PARAMS_ERROR);
}
JsonResult list = offlineSynchService.taskRunNowByTaskId(taskId);
return list;
}
/**
* 根据taskId删除任务
*
* @return
*/
@ApiOperation(value = "删除任务", notes = "删除任务")
@GetMapping(value = "/delTaskByTaskId")
@ApiImplicitParam(name = "taskId", value = "任务id")
public JsonResult delTaskByTaskId(@RequestParam(value = "taskId") String taskId) throws Exception {
if (StringUtils.isEmpty(taskId)) {
return new JsonResult(ResultCode.PARAMS_ERROR);
}
JsonResult list = offlineSynchService.delTaskByTaskId(taskId);
return list;
}
/**
* 状态查看列表分页查询
*
* @return
*/
@ApiOperation(value = "状态查看", notes = "状态查看列表分页查询")
@PostMapping(value = "/checkTaskStatus")
public JsonResult<List<CheckTaskStatusPageDto>> getCheckTaskStatusListPage(@RequestBody @Validated CheckTaskStatusPageReq checkTaskStatusPageReq) throws Exception {
JsonResult<List<CheckTaskStatusPageDto>> list = offlineSynchService.queryCheckTaskStatusListPage(checkTaskStatusPageReq);
return list;
}
}
package com.jz.dmp.modules.controller.DataIntegration.bean;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
/**
* @ClassName: CheckTaskStatusPageDto
* @Description: 状态查看列表返回参数对象
* @Author :Bellamy
* @Date 2020/12/22
* @Version 1.0
*/
@ApiModel(value = "任务状态查看列表返回参数对象", description = "状态查看列表返回参数对象")
public class CheckTaskStatusPageDto {
/*
* 任务执行id
* */
@ApiModelProperty(value = "任务执行id")
private long execId;
/*
* 创建人
* */
@ApiModelProperty(value = "创建人")
private String submitUser;
/*
* 开始时间
* */
@ApiModelProperty(value = "开始时间")
private String startTime;
/*
* 结束时间
* */
@ApiModelProperty(value = "结束时间")
private String endTime;
/*
* 耗时
* */
@ApiModelProperty(value = "耗时")
private long costTime;
/*
*同步状态
* */
@ApiModelProperty(value = "同步状态:FAILED失败,success成功")
private String status;
public long getExecId() {
return execId;
}
public void setExecId(long execId) {
this.execId = execId;
}
public String getSubmitUser() {
return submitUser;
}
public void setSubmitUser(String submitUser) {
this.submitUser = submitUser;
}
public String getStartTime() {
return startTime;
}
public void setStartTime(String startTime) {
this.startTime = startTime;
}
public String getEndTime() {
return endTime;
}
public void setEndTime(String endTime) {
this.endTime = endTime;
}
public long getCostTime() {
return costTime;
}
public void setCostTime(long costTime) {
this.costTime = costTime;
}
public String getStatus() {
return status;
}
public void setStatus(String status) {
this.status = status;
}
}
package com.jz.dmp.modules.controller.DataIntegration.bean;
import com.jz.common.page.BasePageBean;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
/**
* @ClassName: CheckTaskStatusPageReq
* @Description: 状态查看请求参数对象
* @Author:Bellamy
* @Date 2020/12/21
* @Version 1.0
*/
@ApiModel(value = "状态查看列表分页查询请求参数对象", description = "状态查看请求参数对象")
public class CheckTaskStatusPageReq extends BasePageBean {
/*
* 项目ID
* */
@NotNull(message = "项目ID不能为空")
@NotEmpty(message = "项目ID不能空")
@ApiModelProperty(value = "项目ID")
private String projectId;
/*
* 任务id
* */
@ApiModelProperty(value = "任务id")
@NotNull(message = "任务id不能为空")
@NotEmpty(message = "任务id不能为空")
private String taskId;
/*
* 任务树名称
* */
@ApiModelProperty(value = "任务树名称")
@NotEmpty(message = "任务树名称不能为空")
private String treeName;
public String getProjectId() {
return projectId;
}
public void setProjectId(String projectId) {
this.projectId = projectId;
}
public String getTaskId() {
return taskId;
}
public void setTaskId(String taskId) {
this.taskId = taskId;
}
public String getTreeName() {
return treeName;
}
public void setTreeName(String treeName) {
this.treeName = treeName;
}
}
......@@ -25,6 +25,12 @@ public class TaskListPageDto {
@ApiModelProperty(value = "treeId")
String treeId;
/*
* 任务树名称
* */
@ApiModelProperty(value = "任务树名称")
String treeName;
/*
* 同步时间
* */
......@@ -190,4 +196,12 @@ public class TaskListPageDto {
public void setTargetTableName(String targetTableName) {
this.targetTableName = targetTableName;
}
public String getTreeName() {
return treeName;
}
public void setTreeName(String treeName) {
this.treeName = treeName;
}
}
package com.jz.dmp.modules.controller.DataIntegration.bean.flow;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
/**
* @ClassName: FlowExecution
* @Description: TODO(封装同步状态结果)
......@@ -7,22 +10,41 @@ package com.jz.dmp.modules.controller.DataIntegration.bean.flow;
* @date 2020年12月11日
*
*/
@ApiModel(value = "任务状态查看列表返回参数对象", description = "状态查看列表返回参数对象")
public class FlowExecution {
private long submitTime;
/*
* 创建人
* */
@ApiModelProperty(value = "创建人")
private String submitUser;
/*
* 开始时间
* */
@ApiModelProperty(value = "开始时间")
private long startTime;
/*
* 结束时间
* */
@ApiModelProperty(value = "结束时间")
private long endTime;
private String flowId;
/*
* 项目id
* */
@ApiModelProperty(value = "项目id")
private long projectId;
/*
* 任务执行id
* */
@ApiModelProperty(value = "任务执行id")
private long execId;
/*
*同步状态
* */
@ApiModelProperty(value = "同步状态")
private String status;
public long getSubmitTime() {
......
package com.jz.dmp.modules.controller;
import com.jz.dmp.modules.service.DmpDevelopTaskService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
/**
* 任务开发(DmpDevelopTask)表控制层
*
* @author Bellamy
* @since 2020-12-22 16:37:56
*/
@RestController
@RequestMapping("/dmpDevelopTask")
public class DmpDevelopTaskController {
/**
* 服务对象
*/
@Autowired
private DmpDevelopTaskService dmpDevelopTaskService;
}
\ No newline at end of file
package com.jz.dmp.modules.dao;
import java.util.Map;
public interface DmpDevelopTaskDao {
Map getDmpTaskAndTreeInfo(String taskId) throws Exception;
int deleteTaskByTaskId(String taskId) throws Exception;
int deleteNavigationTreeByTreeId(String treeId) throws Exception;
}
......@@ -29,5 +29,5 @@ public interface DmpProjectDao extends CrudDao<DmpProject> {
public List<DmpProjectSystemInfo> getProjectSystemInfo(Long projectId);
DmpProjectSystemInfo queryProjectSystemInfo(@Param("projectId") Integer projectId);
DmpProjectSystemInfo queryProjectSystemInfo(@Param("projectId") Long projectId);
}
package com.jz.dmp.modules.model;
import java.io.Serializable;
import java.util.Date;
/**
* 任务开发(DmpDevelopTask)实体类
*
* @author Bellamy
* @since 2020-12-22 16:37:54
*/
public class DmpDevelopTask implements Serializable {
private static final long serialVersionUID = 492051123327188782L;
/**
* ID
*/
private Integer id;
/**
* 数据源ID
*/
private Integer datasourceId;
/**
* 任务类型
*/
private String taskType;
/**
* 类型
*/
private String type;
/**
* 调度类型
*/
private String scheduleType;
/**
* 是否已提交
*/
private String isSubmit;
/**
* 描述
*/
private String taskDesc;
/**
* 脚本
*/
private Object script;
/**
* 数据状态
*/
private String dataStatus;
/**
* 创建用户ID
*/
private String createUserId;
/**
* 数据创建时间
*/
private Date createTime;
/**
* 创建用户ID
*/
private String updateUserId;
/**
* 数据更新时间
*/
private Date updateTime;
/**
* tree ID
*/
private Integer treeId;
/**
* 校验状态:SUCCEED 成功, FAIL 失败
*/
private String chkResult;
/**
* 同步状态:SUCCEED 成功,FAIL 失败
*/
private String syncResult;
/**
* 最终校验时间
*/
private Date chkTime;
/**
* 最终同步时间
*/
private Date syncTime;
private String flowHeader;
private Object flowJson;
private String version;
private Integer isGziped;
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public Integer getDatasourceId() {
return datasourceId;
}
public void setDatasourceId(Integer datasourceId) {
this.datasourceId = datasourceId;
}
public String getTaskType() {
return taskType;
}
public void setTaskType(String taskType) {
this.taskType = taskType;
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
public String getScheduleType() {
return scheduleType;
}
public void setScheduleType(String scheduleType) {
this.scheduleType = scheduleType;
}
public String getIsSubmit() {
return isSubmit;
}
public void setIsSubmit(String isSubmit) {
this.isSubmit = isSubmit;
}
public String getTaskDesc() {
return taskDesc;
}
public void setTaskDesc(String taskDesc) {
this.taskDesc = taskDesc;
}
public Object getScript() {
return script;
}
public void setScript(Object script) {
this.script = script;
}
public String getDataStatus() {
return dataStatus;
}
public void setDataStatus(String dataStatus) {
this.dataStatus = dataStatus;
}
public String getCreateUserId() {
return createUserId;
}
public void setCreateUserId(String createUserId) {
this.createUserId = createUserId;
}
public Date getCreateTime() {
return createTime;
}
public void setCreateTime(Date createTime) {
this.createTime = createTime;
}
public String getUpdateUserId() {
return updateUserId;
}
public void setUpdateUserId(String updateUserId) {
this.updateUserId = updateUserId;
}
public Date getUpdateTime() {
return updateTime;
}
public void setUpdateTime(Date updateTime) {
this.updateTime = updateTime;
}
public Integer getTreeId() {
return treeId;
}
public void setTreeId(Integer treeId) {
this.treeId = treeId;
}
public String getChkResult() {
return chkResult;
}
public void setChkResult(String chkResult) {
this.chkResult = chkResult;
}
public String getSyncResult() {
return syncResult;
}
public void setSyncResult(String syncResult) {
this.syncResult = syncResult;
}
public Date getChkTime() {
return chkTime;
}
public void setChkTime(Date chkTime) {
this.chkTime = chkTime;
}
public Date getSyncTime() {
return syncTime;
}
public void setSyncTime(Date syncTime) {
this.syncTime = syncTime;
}
public String getFlowHeader() {
return flowHeader;
}
public void setFlowHeader(String flowHeader) {
this.flowHeader = flowHeader;
}
public Object getFlowJson() {
return flowJson;
}
public void setFlowJson(Object flowJson) {
this.flowJson = flowJson;
}
public String getVersion() {
return version;
}
public void setVersion(String version) {
this.version = version;
}
public Integer getIsGziped() {
return isGziped;
}
public void setIsGziped(Integer isGziped) {
this.isGziped = isGziped;
}
}
\ No newline at end of file
package com.jz.dmp.modules.service;
/**
* 任务开发(DmpDevelopTask)表服务接口
*
* @author Bellamy
* @since 2020-12-22 16:37:56
*/
public interface DmpDevelopTaskService {
}
\ No newline at end of file
......@@ -2,6 +2,8 @@ package com.jz.dmp.modules.service;
import com.jz.common.constant.JsonResult;
import com.jz.common.page.PageInfoResponse;
import com.jz.dmp.modules.controller.DataIntegration.bean.CheckTaskStatusPageDto;
import com.jz.dmp.modules.controller.DataIntegration.bean.CheckTaskStatusPageReq;
import com.jz.dmp.modules.controller.DataIntegration.bean.TaskListPageDto;
import com.jz.dmp.modules.controller.DataIntegration.bean.TaskListPageReq;
......@@ -24,4 +26,8 @@ public interface OfflineSynchService {
JsonResult querygSourceTableList(Integer sourceDbId, String targetName) throws Exception;
JsonResult taskRunNowByTaskId(String taskId) throws Exception;
JsonResult delTaskByTaskId(String taskId) throws Exception;
JsonResult<List<CheckTaskStatusPageDto>> queryCheckTaskStatusListPage(CheckTaskStatusPageReq checkTaskStatusPageReq) throws Exception;
}
package com.jz.dmp.modules.service.impl;
import com.jz.dmp.modules.dao.DmpDevelopTaskDao;
import com.jz.dmp.modules.service.DmpDevelopTaskService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
/**
* 任务开发(DmpDevelopTask)表服务实现类
*
* @author Bellamy
* @since 2020-12-22 16:37:56
*/
@Service("dmpDevelopTaskService")
public class DmpDevelopTaskServiceImpl implements DmpDevelopTaskService {
@Autowired
private DmpDevelopTaskDao dmpDevelopTaskDao;
}
\ No newline at end of file
......@@ -12,9 +12,9 @@ import com.jz.common.utils.FileUtils;
import com.jz.common.utils.JsonMapper;
import com.jz.common.utils.ZipUtils;
import com.jz.dmp.agent.DmpAgentResult;
import com.jz.dmp.modules.controller.DataIntegration.bean.SourceDbNameListDto;
import com.jz.dmp.modules.controller.DataIntegration.bean.TaskListPageDto;
import com.jz.dmp.modules.controller.DataIntegration.bean.TaskListPageReq;
import com.jz.dmp.modules.controller.DataIntegration.bean.*;
import com.jz.dmp.modules.controller.DataIntegration.bean.flow.FlowExecution;
import com.jz.dmp.modules.dao.DmpDevelopTaskDao;
import com.jz.dmp.modules.dao.DmpProjectDao;
import com.jz.dmp.modules.dao.OfflineSynchDao;
import com.jz.dmp.modules.model.DmpAgentDatasourceInfo;
......@@ -53,6 +53,9 @@ public class OfflineSynchServiceImpl implements OfflineSynchService {
@Autowired
private DmpProjectDao dmpProjectDao;
@Autowired
private DmpDevelopTaskDao dmpDevelopTaskDao;
@Autowired
private DmpDsAgentService dmpDsAgentServiceImp;
......@@ -74,6 +77,9 @@ public class OfflineSynchServiceImpl implements OfflineSynchService {
return pageInfoResponse;
}
/**
* 获取源数据库名称——下拉框
*/
@Override
public JsonResult<List<SourceDbNameListDto>> querygSourceDbList(Integer projectId) throws Exception {
Map map = new HashMap();
......@@ -83,6 +89,9 @@ public class OfflineSynchServiceImpl implements OfflineSynchService {
return new JsonResult(ResultCode.SUCCESS, list);
}
/**
* 根据源数据库id,获取源数据表——下拉框
*/
@Override
public JsonResult querygSourceTableList(Integer sourceDbId, String targetName) throws Exception {
//通过源数据库id ,查询数据源配置
......@@ -110,18 +119,25 @@ public class OfflineSynchServiceImpl implements OfflineSynchService {
*/
@Override
public JsonResult taskRunNowByTaskId(String taskId) throws Exception {
boolean flag = false;
//根据任务id,查询DMP资源导航树和DW系统配置信息
Map<String,Object> map = offlineSynchDao.selectNavigationTreeByTaskId(taskId);
Map<String, Object> map = offlineSynchDao.selectNavigationTreeByTaskId(taskId);
if (map.size() > 0 && map != null) {
this.publish(map);
flag = this.publish(map);
if (flag) {
return new JsonResult(ResultCode.SUCCESS, flag);
} else {
return new JsonResult(ResultCode.SYS_ERROR, flag);
}
} else {
return new JsonResult(ResultCode.SYS_ERROR, flag);
}
return null;
}
/**
* 发布流程
*/
private boolean publish(Map<String,Object> map) {
private boolean publish(Map<String, Object> map) {
String taskId = map.get("taskId").toString(); //任务id
String projectId = map.get("projectId").toString(); //项目id
String treeName = map.get("treeName").toString(); //流程名称
......@@ -182,4 +198,57 @@ public class OfflineSynchServiceImpl implements OfflineSynchService {
return azkabanApiUtils.loginCreateProjectuploadZipAndExecute("jz_localflow_" + projectId, "local_sync_project", localTaskZipAbsolutePath, treeName);
}
/**
* 删除任务
*/
@Override
public JsonResult delTaskByTaskId(String taskId) throws Exception {
//通过taskId,查询任务和资源是否存在
Map map = dmpDevelopTaskDao.getDmpTaskAndTreeInfo(taskId);
if (map.size() == 0 || map == null) {
return new JsonResult(ResultCode.OPERATION_DATA_NO_EXIST);
}
if (StringUtils.isEmpty(map.get("treeId").toString())) {
return new JsonResult(ResultCode.OPERATION_DATA_NO_EXIST);
}
dmpDevelopTaskDao.deleteTaskByTaskId(taskId);
dmpDevelopTaskDao.deleteNavigationTreeByTreeId(map.get("treeId").toString());
return new JsonResult(ResultCode.SUCCESS);
}
@Override
public JsonResult<List<CheckTaskStatusPageDto>> queryCheckTaskStatusListPage(CheckTaskStatusPageReq checkTaskStatusPageReq) throws Exception {
List<FlowExecution> list = new ArrayList<>();
Long projectId = Long.valueOf(checkTaskStatusPageReq.getProjectId());
String treeName = checkTaskStatusPageReq.getTreeName();
DmpProjectSystemInfo publishToProjectSystemInfo = dmpProjectDao.queryProjectSystemInfo(projectId);
//调用azkaban服务
String azkabanApiUrl = publishToProjectSystemInfo.getAzkabanMonitorUrl();
AzkabanApiUtils2 azkabanApiUtils = new AzkabanApiUtils2(azkabanApiUrl);
list = azkabanApiUtils.getSyncingFlowExecution(projectId, treeName, checkTaskStatusPageReq.getPageNum(), checkTaskStatusPageReq.getPageSize());
List<CheckTaskStatusPageDto> returnList = new ArrayList<>();
if (list.size() > 0 && list != null) {
for (FlowExecution str : list) {
CheckTaskStatusPageDto dto = new CheckTaskStatusPageDto();
long endTime = str.getEndTime();
long execId = str.getExecId();
long startTime = str.getStartTime();
String status = str.getStatus();
String submitUser = str.getSubmitUser();
long costTime = endTime - startTime;
dto.setCostTime(costTime);
dto.setExecId(execId);
dto.setStatus(status);
dto.setSubmitUser(submitUser);
returnList.add(dto);
}
}
return new JsonResult(ResultCode.SUCCESS, list);
}
}
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="com.jz.dmp.modules.dao.DmpDevelopTaskDao" >
<select id="getDmpTaskAndTreeInfo" parameterType="string" resultType="map">
select
t1.ID as taskId,
t1.TREE_ID as treeId
from dmp_develop_task t1
left join dmp_navigation_tree t2 on t1.TREE_ID=t2.ID
where 1=1 and t1.id = #{taskId}
</select>
<!--根据主键删除任务-->
<delete id="deleteTaskByTaskId" parameterType="string">
delete from dmp_develop_task where id = #{taskId}
</delete>
<!--根据主键删除资源树-->
<delete id="deleteNavigationTreeByTreeId" parameterType="string">
delete from dmp_navigation_tree where id = #{treeId}
</delete>
</mapper>
\ No newline at end of file
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