mirror of
https://gitee.com/wangkang/udf.git
synced 2026-10-20 22:23:49 +00:00
更新
This commit is contained in:
+4
-4
@@ -1,5 +1,5 @@
|
||||
/**
|
||||
* IExecute.java
|
||||
* IExecutor.java
|
||||
* Created at 2017-06-11
|
||||
* Created by Administrator
|
||||
* Copyright (C) 2016 egridcloud.com, All rights reserved.
|
||||
@@ -9,18 +9,18 @@ package com.egridcloud.udf.scheduler.client;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 描述 : IExecute
|
||||
* 描述 : IExecutor
|
||||
*
|
||||
* @author Administrator
|
||||
*
|
||||
*/
|
||||
public interface IExecute {
|
||||
public interface IExecutor {
|
||||
|
||||
/**
|
||||
* 描述 : 执行方法
|
||||
*
|
||||
* @param jobDataMap jobDataMap
|
||||
*/
|
||||
public void execute(Map<String, Object> jobDataMap);
|
||||
public void handle(Map<String, Object> jobDataMap);
|
||||
|
||||
}
|
||||
+3
-3
@@ -1,5 +1,5 @@
|
||||
/**
|
||||
* GeneralJobParam.java
|
||||
* RmsJobParam.java
|
||||
* Created at 2017-06-04
|
||||
* Created by Administrator
|
||||
* Copyright (C) 2016 egridcloud.com, All rights reserved.
|
||||
@@ -13,13 +13,13 @@ import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
|
||||
/**
|
||||
* 描述 : GeneralJobParam
|
||||
* 描述 : RmsJobParam
|
||||
*
|
||||
* @author Administrator
|
||||
*
|
||||
*/
|
||||
@ApiModel(description = "通用job参数")
|
||||
public class GeneralJobParam implements Serializable {
|
||||
public class RmsJobParam implements Serializable {
|
||||
|
||||
/**
|
||||
* 描述 : ID
|
||||
+6
-6
@@ -1,5 +1,5 @@
|
||||
/**
|
||||
* GeneralJobParam.java
|
||||
* RmsJobResult.java
|
||||
* Created at 2017-06-04
|
||||
* Created by Administrator
|
||||
* Copyright (C) 2016 egridcloud.com, All rights reserved.
|
||||
@@ -13,13 +13,13 @@ import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
|
||||
/**
|
||||
* 描述 : GeneralJobParam
|
||||
* 描述 : RmsJobResult
|
||||
*
|
||||
* @author Administrator
|
||||
*
|
||||
*/
|
||||
@ApiModel(description = "通用job返回值")
|
||||
public class GeneralJobResult implements Serializable {
|
||||
public class RmsJobResult implements Serializable {
|
||||
|
||||
/**
|
||||
* 描述 : ID
|
||||
@@ -36,7 +36,7 @@ public class GeneralJobResult implements Serializable {
|
||||
* 描述 : 参数
|
||||
*/
|
||||
@ApiModelProperty(value = "参数", required = true, dataType = "object")
|
||||
private GeneralJobParam param;
|
||||
private RmsJobParam param;
|
||||
|
||||
/**
|
||||
* 描述 : 客户端初始化时间
|
||||
@@ -115,7 +115,7 @@ public class GeneralJobResult implements Serializable {
|
||||
*
|
||||
* @return the param
|
||||
*/
|
||||
public GeneralJobParam getParam() {
|
||||
public RmsJobParam getParam() {
|
||||
return param;
|
||||
}
|
||||
|
||||
@@ -124,7 +124,7 @@ public class GeneralJobResult implements Serializable {
|
||||
*
|
||||
* @param param the param to set
|
||||
*/
|
||||
public void setParam(GeneralJobParam param) {
|
||||
public void setParam(RmsJobParam param) {
|
||||
this.param = param;
|
||||
}
|
||||
|
||||
+3
-3
@@ -11,8 +11,8 @@ import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMethod;
|
||||
|
||||
import com.egridcloud.udf.core.RestResponse;
|
||||
import com.egridcloud.udf.scheduler.client.domain.GeneralJobParam;
|
||||
import com.egridcloud.udf.scheduler.client.domain.GeneralJobResult;
|
||||
import com.egridcloud.udf.scheduler.client.domain.RmsJobParam;
|
||||
import com.egridcloud.udf.scheduler.client.domain.RmsJobResult;
|
||||
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiImplicitParam;
|
||||
@@ -46,6 +46,6 @@ public interface ISchClientController {
|
||||
@ApiImplicitParam(paramType = "header", name = "rmsServiceCode", value = "rms接口编号",
|
||||
required = true, dataType = "string") })
|
||||
@RequestMapping(method = RequestMethod.POST)
|
||||
public RestResponse<GeneralJobResult> execute(@RequestBody GeneralJobParam param);
|
||||
public RestResponse<RmsJobResult> execute(@RequestBody RmsJobParam param);
|
||||
|
||||
}
|
||||
|
||||
+7
-7
@@ -15,10 +15,10 @@ import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import com.egridcloud.udf.core.RestResponse;
|
||||
import com.egridcloud.udf.scheduler.client.IExecute;
|
||||
import com.egridcloud.udf.scheduler.client.IExecutor;
|
||||
import com.egridcloud.udf.scheduler.client.SchException;
|
||||
import com.egridcloud.udf.scheduler.client.domain.GeneralJobParam;
|
||||
import com.egridcloud.udf.scheduler.client.domain.GeneralJobResult;
|
||||
import com.egridcloud.udf.scheduler.client.domain.RmsJobParam;
|
||||
import com.egridcloud.udf.scheduler.client.domain.RmsJobResult;
|
||||
|
||||
/**
|
||||
* 描述 : SchClientController
|
||||
@@ -35,11 +35,11 @@ public class SchClientController implements ISchClientController, ApplicationCon
|
||||
private ApplicationContext applicationContext;
|
||||
|
||||
@Override
|
||||
public RestResponse<GeneralJobResult> execute(@RequestBody GeneralJobParam param) {
|
||||
public RestResponse<RmsJobResult> execute(@RequestBody RmsJobParam param) {
|
||||
//客户端初始化时间
|
||||
Date clientInitTime = new Date();
|
||||
//定义返回值
|
||||
GeneralJobResult result = new GeneralJobResult();
|
||||
RmsJobResult result = new RmsJobResult();
|
||||
result.setFireInstanceId(param.getFireInstanceId());
|
||||
result.setParam(param);
|
||||
//判断bean是否存在
|
||||
@@ -47,11 +47,11 @@ public class SchClientController implements ISchClientController, ApplicationCon
|
||||
throw new SchException(param.getBeanName() + " not definition");
|
||||
}
|
||||
//获得bean
|
||||
IExecute bean = applicationContext.getBean(param.getBeanName(), IExecute.class);
|
||||
IExecutor bean = applicationContext.getBean(param.getBeanName(), IExecutor.class);
|
||||
//客户端开始时间
|
||||
Date clientStartExecuteTime = new Date();
|
||||
//执行
|
||||
bean.execute(param.getJobDataMap());
|
||||
bean.handle(param.getJobDataMap());
|
||||
//客户端结束时间
|
||||
Date clientEndExecuteTime = new Date();
|
||||
//设置返回值
|
||||
|
||||
+5
-5
@@ -1,26 +1,26 @@
|
||||
/**
|
||||
* IGeneralJobResult.java
|
||||
* IRmsJobLog.java
|
||||
* Created at 2017-06-11
|
||||
* Created by Administrator
|
||||
* Copyright (C) 2016 egridcloud.com, All rights reserved.
|
||||
*/
|
||||
package com.egridcloud.udf.scheduler;
|
||||
|
||||
import com.egridcloud.udf.scheduler.client.domain.GeneralJobResult;
|
||||
import com.egridcloud.udf.scheduler.client.domain.RmsJobResult;
|
||||
|
||||
/**
|
||||
* 描述 : IGeneralJobResult
|
||||
* 描述 : IRmsJobLog
|
||||
*
|
||||
* @author Administrator
|
||||
*
|
||||
*/
|
||||
public interface IGeneralJobResult {
|
||||
public interface IRmsJobLog {
|
||||
|
||||
/**
|
||||
* 描述 : save
|
||||
*
|
||||
* @param generalJobResult generalJobResult
|
||||
*/
|
||||
public void save(GeneralJobResult generalJobResult);
|
||||
public void save(RmsJobResult generalJobResult);
|
||||
|
||||
}
|
||||
+17
-18
@@ -1,5 +1,5 @@
|
||||
/**
|
||||
* GeneralJob.java
|
||||
* RmsJob.java
|
||||
* Created at 2017-06-04
|
||||
* Created by Administrator
|
||||
* Copyright (C) 2016 egridcloud.com, All rights reserved.
|
||||
@@ -18,19 +18,19 @@ import org.springframework.http.ResponseEntity;
|
||||
|
||||
import com.egridcloud.udf.core.RestResponse;
|
||||
import com.egridcloud.udf.rms.Rms;
|
||||
import com.egridcloud.udf.scheduler.IGeneralJobResult;
|
||||
import com.egridcloud.udf.scheduler.IRmsJobLog;
|
||||
import com.egridcloud.udf.scheduler.client.SchException;
|
||||
import com.egridcloud.udf.scheduler.client.domain.GeneralJobParam;
|
||||
import com.egridcloud.udf.scheduler.client.domain.GeneralJobResult;
|
||||
import com.egridcloud.udf.scheduler.client.domain.RmsJobParam;
|
||||
import com.egridcloud.udf.scheduler.client.domain.RmsJobResult;
|
||||
|
||||
/**
|
||||
* 描述 : GeneralJob
|
||||
* 描述 : RmsJob
|
||||
*
|
||||
* @author Administrator
|
||||
*
|
||||
*/
|
||||
@DisallowConcurrentExecution
|
||||
public class GeneralJob extends AbstractBaseJob {
|
||||
public class RmsJob extends AbstractBaseJob {
|
||||
|
||||
@Override
|
||||
protected void executeInternal(JobExecutionContext jobExecutionContext)
|
||||
@@ -50,20 +50,20 @@ public class GeneralJob extends AbstractBaseJob {
|
||||
//获得RMS
|
||||
Rms rms = this.getApplicationContext().getBean(Rms.class);
|
||||
//封装请求参数
|
||||
GeneralJobParam generalJobParam = new GeneralJobParam();
|
||||
generalJobParam.setFireInstanceId(jobExecutionContext.getFireInstanceId());
|
||||
generalJobParam.setBeanName(beanName);
|
||||
generalJobParam.setJobDataMap(jobDataMap.getWrappedMap());
|
||||
RmsJobParam rmsJobParam = new RmsJobParam();
|
||||
rmsJobParam.setFireInstanceId(jobExecutionContext.getFireInstanceId());
|
||||
rmsJobParam.setBeanName(beanName);
|
||||
rmsJobParam.setJobDataMap(jobDataMap.getWrappedMap());
|
||||
//请求
|
||||
ResponseEntity<RestResponse<GeneralJobResult>> result = rms.call(serviceCode, generalJobParam,
|
||||
null, new ParameterizedTypeReference<RestResponse<GeneralJobResult>>() {
|
||||
ResponseEntity<RestResponse<RmsJobResult>> result = rms.call(serviceCode, rmsJobParam, null,
|
||||
new ParameterizedTypeReference<RestResponse<RmsJobResult>>() {
|
||||
}, null);
|
||||
//判断http状态
|
||||
if (result.getStatusCode() != HttpStatus.OK) {
|
||||
throw new SchException(result.getStatusCode().toString());
|
||||
}
|
||||
//记录结果
|
||||
saveGeneralJobResult(result.getBody().getResult());
|
||||
saveRmsJobResult(result.getBody().getResult());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -71,12 +71,11 @@ public class GeneralJob extends AbstractBaseJob {
|
||||
*
|
||||
* @param result result
|
||||
*/
|
||||
private void saveGeneralJobResult(GeneralJobResult result) {
|
||||
String[] beanNames = this.getApplicationContext().getBeanNamesForType(IGeneralJobResult.class);
|
||||
private void saveRmsJobResult(RmsJobResult result) {
|
||||
String[] beanNames = this.getApplicationContext().getBeanNamesForType(IRmsJobLog.class);
|
||||
if (ArrayUtils.isNotEmpty(beanNames)) {
|
||||
IGeneralJobResult generalJobResultService =
|
||||
this.getApplicationContext().getBean(IGeneralJobResult.class);
|
||||
generalJobResultService.save(result);
|
||||
IRmsJobLog rmsJobLog = this.getApplicationContext().getBean(IRmsJobLog.class);
|
||||
rmsJobLog.save(result);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user