| | |
| | | import org.springframework.beans.factory.annotation.Value;
|
| | | import org.springframework.boot.context.properties.ConfigurationProperties;
|
| | | import org.springframework.http.*;
|
| | | import org.springframework.http.client.SimpleClientHttpRequestFactory;
|
| | | import org.springframework.http.converter.StringHttpMessageConverter;
|
| | | import org.springframework.stereotype.Component;
|
| | | import org.springframework.util.LinkedMultiValueMap;
|
| | | import org.springframework.util.MultiValueMap;
|
| | | import org.springframework.util.StringUtils;
|
| | | import org.springframework.web.client.RestTemplate;
|
| | |
|
| | | import java.nio.charset.StandardCharsets;
|
| | | import java.util.HashMap;
|
| | | import java.util.LinkedHashMap;
|
| | | import java.util.Map;
|
| | |
|
| | | @Slf4j
|
| | |
| | | }
|
| | | public boolean login() {
|
| | | String url = this.url + prefix + "login";
|
| | | MultiValueMap<String, String> params = new LinkedMultiValueMap<>();
|
| | | params.set("userName","mdmadmin");
|
| | | params.set("password","datacvg123");
|
| | | params.set("ifRemember","false");
|
| | | Map<String, String> params = new LinkedHashMap<>();
|
| | | params.put("userName","mdmadmin");
|
| | | params.put("password","datacvg123");
|
| | | params.put("ifRemember","false");
|
| | | Map<String, Object> paramMap = new HashMap<>();
|
| | | paramMap.putAll(params);
|
| | | String urlParamsByMap = HttpUtils.getUrlParamsByMap(paramMap);
|
| | |
| | | public boolean saveJobGroup() {
|
| | | try {
|
| | | String url = this.url + prefix + "xxlcustapi/saveJobGroup";
|
| | | MultiValueMap<String, String> params = new LinkedMultiValueMap<>();
|
| | | params.set("appName","MDMApp");
|
| | | params.set("order", "1");
|
| | | params.set("title","数据汇集定时任务执行器");
|
| | | params.set("modelId","MDM");
|
| | | params.set("addressType","1");
|
| | | params.set("addressList",local);
|
| | | Map<String, String> params = new LinkedHashMap<>();
|
| | | params.put("appName","MDMApp");
|
| | | params.put("order", "1");
|
| | | params.put("title","数据汇集定时任务执行器");
|
| | | params.put("modelId","MDM");
|
| | | params.put("addressType","1");
|
| | | params.put("addressList",local);
|
| | | String s = null;
|
| | | Map<String, Object> paramMap = new HashMap<>();
|
| | | paramMap.putAll(params);
|
| | | String urlParamsByMap = HttpUtils.getUrlParamsByMap(paramMap);
|
| | |
|
| | | s = HttpRestClient(url, HttpMethod.POST, null, urlParamsByMap, MediaType.APPLICATION_JSON);
|
| | |
|
| | | JSONObject result = (JSONObject) JSON.parse(s);
|
| | | boolean success = parse(result);
|
| | | if (!success){
|
| | | log.error("请求saveJobGroup失败:" + result.getString("msg"));
|
| | | }
|
| | | return success;
|
| | | }catch (Exception e){
|
| | | e.printStackTrace();
|
| | | return false;
|
| | | }
|
| | |
|
| | | }
|
| | |
|
| | | public boolean saveAutoJobGroup() {
|
| | | try {
|
| | | String url = this.url + prefix + "xxlcustapi/saveJobGroup";
|
| | | Map<String, String> params = new LinkedHashMap<>();
|
| | | params.put("appName","MDMApp");
|
| | | params.put("order", "1");
|
| | | params.put("title","数据汇集定时任务执行器");
|
| | | params.put("modelId","MDM");
|
| | | params.put("addressType","0");
|
| | | // params.put("addressList",local);
|
| | | String s = null;
|
| | | Map<String, Object> paramMap = new HashMap<>();
|
| | | paramMap.putAll(params);
|
| | |
| | | public boolean removeJobGroup() {
|
| | | try {
|
| | | String url = this.url + prefix + "xxlcustapi/saveJobGroup";
|
| | | MultiValueMap<String, String> params = new LinkedMultiValueMap<>();
|
| | | params.set("modelid","MDM");
|
| | | Map<String, String> params = new LinkedHashMap<>();
|
| | | params.put("modelid","MDM");
|
| | | Map<String, Object> paramMap = new HashMap<>();
|
| | | paramMap.putAll(params);
|
| | | String urlParamsByMap = HttpUtils.getUrlParamsByMap(paramMap);
|
| | |
| | | try {
|
| | | String jobId = createJobId(assemble.getId());
|
| | | String url = this.url + prefix + "xxlcustapi/addJob";
|
| | | MultiValueMap<String, String> params = new LinkedMultiValueMap<>();
|
| | | params.set("modelId","MDM");
|
| | | params.set("modelJobId", jobId);
|
| | | params.set("jobCron",assemble.getCron());
|
| | | params.set("author",assemble.getUserId());
|
| | | params.set("executorHandler","assembleJob");
|
| | | params.set("executorParam",assemble.getId());
|
| | | params.set("cronGen_display",assemble.getCron());
|
| | | params.set("executorBlockStrategy","DISCARD_LATER");
|
| | | params.set("executorTimeout","0");
|
| | | params.set("executorFailRetryCount","3");
|
| | | params.set("triggerStatus","1");
|
| | | params.set("glueType","BEAN");
|
| | | params.set("executorRouteStrategy","FIRST");
|
| | | params.set("jobDesc","创建汇集job");
|
| | | Map<String, String> params = new LinkedHashMap<>();
|
| | | params.put("modelId","MDM");
|
| | | params.put("modelJobId", jobId);
|
| | | params.put("jobCron",assemble.getCron());
|
| | | params.put("author",assemble.getUserId());
|
| | | params.put("executorHandler","assembleJob");
|
| | | params.put("executorParam",assemble.getId());
|
| | | params.put("cronGen_display",assemble.getCron());
|
| | | params.put("executorBlockStrategy","DISCARD_LATER");
|
| | | params.put("executorTimeout","0");
|
| | | params.put("executorFailRetryCount","0");
|
| | | params.put("triggerStatus","1");
|
| | | params.put("glueType","BEAN");
|
| | | params.put("executorRouteStrategy","FIRST");
|
| | | params.put("jobDesc","创建汇集job" + jobId);
|
| | | Map<String, Object> paramMap = new HashMap<>();
|
| | | paramMap.putAll(params);
|
| | | String urlParamsByMap = HttpUtils.getUrlParamsByMap(paramMap);
|
| | |
| | | id = DbUtils.getUUID();
|
| | | }
|
| | | try {
|
| | | String jobId = "MDM-" + DbUtils.Bit16(id);
|
| | | String jobId = "MDM-" + id;
|
| | | return jobId;
|
| | | } catch (Exception e) {
|
| | | e.printStackTrace();
|
| | |
| | |
|
| | | public boolean updateJob(SysAssemble assemble) {
|
| | | try {
|
| | | String jobId = createJobId(assemble.getId());
|
| | | String url = this.url + prefix + "xxlcustapi/updateJob";
|
| | | MultiValueMap<String, String> params = new LinkedMultiValueMap<>();
|
| | | params.set("modelId","MDM");
|
| | | params.set("modelJobId",assemble.getJobId());
|
| | | params.set("jobCron",assemble.getCron());
|
| | | params.set("author",assemble.getUserId());
|
| | | params.set("executorHandler","assembleJob");
|
| | | params.set("executorParam",assemble.getId());
|
| | | params.set("cronGen_display",assemble.getCron());
|
| | | params.set("executorBlockStrategy","DISCARD_LATER");
|
| | | params.set("executorTimeout","0");
|
| | | params.set("executorFailRetryCount","3");
|
| | | params.set("triggerStatus","1");
|
| | | params.set("glueType","BEAN");
|
| | | params.set("executorRouteStrategy","FIRST");
|
| | | params.set("jobDesc","更新汇集job");
|
| | | Map<String, String> params = new LinkedHashMap<>();
|
| | | params.put("modelId","MDM");
|
| | | params.put("modelJobId",assemble.getJobId());
|
| | | params.put("jobCron",assemble.getCron());
|
| | | params.put("author",assemble.getUserId());
|
| | | params.put("executorHandler","assembleJob");
|
| | | params.put("executorParam",assemble.getId());
|
| | | params.put("cronGen_display",assemble.getCron());
|
| | | params.put("executorBlockStrategy","DISCARD_LATER");
|
| | | params.put("executorTimeout","0");
|
| | | params.put("executorFailRetryCount","3");
|
| | | params.put("triggerStatus","1");
|
| | | params.put("glueType","BEAN");
|
| | | params.put("executorRouteStrategy","FIRST");
|
| | | params.put("jobDesc","更新汇集job" + jobId);
|
| | | Map<String, Object> paramMap = new HashMap<>();
|
| | | paramMap.putAll(params);
|
| | | String urlParamsByMap = HttpUtils.getUrlParamsByMap(paramMap);
|
| | |
| | |
|
| | | try {
|
| | | String url = this.url + prefix + "xxlcustapi/removeJob";
|
| | | MultiValueMap<String, String> params = new LinkedMultiValueMap<>();
|
| | | params.set("modelId","MDM");
|
| | | params.set("modelJobId", jobId);
|
| | | Map<String, String> params = new LinkedHashMap<>();
|
| | | params.put("modelId","MDM");
|
| | | params.put("modelJobId", jobId);
|
| | |
|
| | | Map<String, Object> paramMap = new HashMap<>();
|
| | | paramMap.putAll(params);
|
| | |
| | | }
|
| | | try {
|
| | | String url = this.url + prefix + "xxlcustapi/queryJobLogById";
|
| | | MultiValueMap<String, String> params = new LinkedMultiValueMap<>();
|
| | | params.set("modelId","MDM");
|
| | | params.set("modelJobId", assemble.getJobId());
|
| | | Map<String, String> params = new LinkedHashMap<>();
|
| | | params.put("modelId","MDM");
|
| | | params.put("modelJobId", assemble.getJobId());
|
| | |
|
| | | Map<String, Object> paramMap = new HashMap<>();
|
| | | paramMap.putAll(params);
|
| | |
| | | }
|
| | | try {
|
| | | String url = this.url + prefix + "xxlcustapi/trigger";
|
| | | MultiValueMap<String, String> params = new LinkedMultiValueMap<>();
|
| | | params.set("modelId","MDM");
|
| | | params.set("modelJobId", assemble.getJobId());
|
| | | params.set("executorParam", assemble.getId());
|
| | | Map<String, String> params = new LinkedHashMap<>();
|
| | | params.put("modelId","MDM");
|
| | | params.put("modelJobId", assemble.getJobId());
|
| | | params.put("executorParam", assemble.getId());
|
| | |
|
| | | Map<String, Object> paramMap = new HashMap<>();
|
| | | paramMap.putAll(params);
|
| | |
| | | }
|
| | |
|
| | |
|
| | | private String HttpRestClient(String url, HttpMethod method, MultiValueMap<String, String> formParams, String getParams, MediaType mediaType) {
|
| | | private String HttpRestClient(String url, HttpMethod method, Map<String, String> formParams, String getParams, MediaType mediaType) {
|
| | | if (!StringUtils.isEmpty(getParams)) {
|
| | | url = url + Constant.QUESTION + getParams;
|
| | | }
|
| | |
| | | headers.setContentType(mediaType);
|
| | | }
|
| | |
|
| | | HttpEntity<MultiValueMap<String, String>> requestEntity = new HttpEntity<MultiValueMap<String, String>>(formParams, headers);
|
| | | HttpEntity<Map<String, String>> requestEntity = new HttpEntity<Map<String, String>>(formParams, headers);
|
| | | // 执行HTTP请求
|
| | | ResponseEntity<String> response = client.exchange(url, method, requestEntity, String.class);
|
| | |
|