BSP 脚本

yun-zuoyi
castle.zang 3 years ago
parent 0107aab563
commit fa91cf6804

@ -14,12 +14,13 @@ public class BspEnumUtil {
@JsonFormat(shape = JsonFormat.Shape.OBJECT)
public enum PARAM_TYPE {
METHOD_PARAM_TYPE(10,"method","方法参数"),
SCRIPT_PARAM_TYPE(20,"script","脚本参数");
METHOD_PARAM_TYPE(10, "method", "方法参数"),
SCRIPT_PARAM_TYPE(20, "script", "脚本参数");
private Integer value;
private String code;
private String description;
PARAM_TYPE(Integer value,String code,String description){
PARAM_TYPE(Integer value, String code, String description) {
this.value = value;
this.code = code;
this.description = description;
@ -87,11 +88,51 @@ public class BspEnumUtil {
}
/**
* GroovyPythonJavaScriptScalaRuby
*
* language_type
*/
@JsonFormat(shape = JsonFormat.Shape.OBJECT)
public enum SCRIPT_TYPE {
GROOVY(10, "groovyScript"),
PYTHON(20, "pythonScript"),
JAVA_SCRIPT(30, "javaScript"),
SCALA(40, "scalaScript"),
RUBY(50, "rubyScript");
private int value;
private String beanName;
SCRIPT_TYPE(int value, String beanName) {
this.value = value;
this.beanName = beanName;
}
public int getValue() {
return value;
}
public String getBeanName() {
return beanName;
}
public static String valueOfBeanName(int val) {
String tmp = null;
for (int i = 0; i < values().length; i++) {
if (values()[i].value == val) {
tmp = values()[i].beanName;
}
}
return tmp;
}
}
/**
*
*/
@JsonFormat(shape = JsonFormat.Shape.OBJECT)
public enum METHOD_GROUP_TYPE {
BSP(10,"BSP"),
BSP(10, "BSP"),
WMS(20, "WMS"),
MES(30, "MES"),
APS(40, "APS"),
@ -123,4 +164,40 @@ public class BspEnumUtil {
return tmp;
}
}
/**
*
*/
@JsonFormat(shape = JsonFormat.Shape.OBJECT)
public enum METHOD_OR_SCRIPT {
METHOD(10, "METHOD"),
SCRIPT(20, "SCRIPT");
private int value;
private String description;
METHOD_OR_SCRIPT(int value, String description) {
this.value = value;
this.description = description;
}
public int getValue() {
return value;
}
public String getDescription() {
return description;
}
public static String valueOfDescription(int val) {
String tmp = null;
for (int i = 0; i < values().length; i++) {
if (values()[i].value == val) {
tmp = values()[i].description;
}
}
return tmp;
}
}
}

@ -1,56 +0,0 @@
//package cn.estsh.i3plus.pojo.bsp.common;
//
//import java.io.Serializable;
//
///**
// * @author Castle
// */
//public class ReturnT<T> implements Serializable {
// public static final long serialVersionUID = 42L;
//
// public static final int SUCCESS_CODE = 200;
// public static final int FAIL_CODE = 500;
//
// public static final ReturnT<String> SUCCESS = new ReturnT<String>(null);
// public static final ReturnT<String> FAIL = new ReturnT<String>(FAIL_CODE, null);
//
// private int code;
// private String msg;
// private T content;
//
// public ReturnT(){}
// public ReturnT(int code, String msg) {
// this.code = code;
// this.msg = msg;
// }
//
// public ReturnT(T content) {
// this.code = SUCCESS_CODE;
// this.content = content;
// }
//
// public int getCode() {
// return code;
// }
// public void setCode(int code) {
// this.code = code;
// }
// public String getMsg() {
// return msg;
// }
// public void setMsg(String msg) {
// this.msg = msg;
// }
// public T getContent() {
// return content;
// }
// public void setContent(T content) {
// this.content = content;
// }
//
// @Override
// public String toString() {
// return "ReturnT [code=" + code + ", msg=" + msg + ", content=" + content + "]";
// }
//
//}

@ -0,0 +1,30 @@
package cn.estsh.i3plus.pojo.bsp.common.script.strategy;
import groovy.lang.GroovyClassLoader;
import groovy.lang.GroovyObject;
import java.util.Map;
import java.util.Set;
/**
* @Description : executeexecutegroovyexecute
* @Reference :
* @Author : Castle
* @CreateDate : 2022/1/26 15:03
* @Modify:
**/
public class GroovyScript implements Script{
@Override
public Map<String, Object> execute(String script,Map<String, Object> paramMap,String methodName) throws IllegalAccessException, InstantiationException {
Class scriptClass = new GroovyClassLoader().parseClass(script);
GroovyObject groovyObject = (GroovyObject) scriptClass.newInstance();
Set<String> keys = paramMap.keySet();
keys.forEach(key ->{
groovyObject.setProperty(key,paramMap.get(key));
});
methodName = methodName != null ? methodName : "execute";
Map<String, Object> resultMap = (Map<String, Object>)groovyObject.invokeMethod(methodName,null);
return resultMap;
}
}

@ -0,0 +1,21 @@
package cn.estsh.i3plus.pojo.bsp.common.script.strategy;
import java.util.Map;
/**
* @Description :
* @Reference :
* @Author : Castle
* @CreateDate : 2022/1/26 15:02
* @Modify:
**/
public interface Script {
/**
*
* @param script
* @param paramMap
* @param methodName
* @return
*/
Map<String,Object> execute(String script,Map<String, Object> paramMap,String methodName) throws IllegalAccessException, InstantiationException;
}

@ -22,7 +22,7 @@ import java.util.List;
public class MethodGroupModel {
@ApiModelProperty("方法组id")
private Long methodGroupId;
private Long id;
@ApiModelProperty("方法组的名称")
private String methodGroupName;
@ -36,4 +36,7 @@ public class MethodGroupModel {
@ApiModelProperty("方法组分类")
private Integer classification;
@ApiModelProperty("链接关系")
private String connections;
}

@ -27,4 +27,12 @@ public class RequestModel {
private Map<String, Object> jsonParamMap;
@ApiModelProperty("日志id")
private Long logId;
@ApiModelProperty("方法类型-脚本-方法")
private Integer type;
@ApiModelProperty("脚本类型")
private Integer scriptType;
@ApiModelProperty("脚本内容")
private String scriptContent;
@ApiModelProperty("脚本执行位置")
private Integer scriptExecutor;
}

@ -48,4 +48,8 @@ public class ExecutorRegistryInfo extends BaseBean implements Serializable {
@Column(name = "HEART_BEAT")
@ApiModelProperty("心跳存活12死掉")
private Integer heartBeat;
@Column(name = "EXECUTOR_TYPE")
@ApiModelProperty("执行器的类型同枚举Method_group_Type")
private Integer executorType;
}

@ -50,6 +50,10 @@ public class ExecutorRegistryMethodInfo extends BaseBean implements Serializable
@ApiModelProperty("所属执行器的appName")
private String appName;
@Column(name = "METHOD_TYPE")
@ApiModelProperty("方法类型,属于那个执行器类型,同枚举类method_group_type")
private Integer methodType;
@Column(name = "description")
@ApiModelProperty("方法描述")
private String description;

@ -7,6 +7,7 @@ import lombok.*;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Lob;
import javax.persistence.Table;
import java.io.Serializable;
@ -42,5 +43,8 @@ public class MethodGroupInfo extends BaseBean implements Serializable {
@ApiModelProperty("方法组分类,挂载到的wms,mes等,枚举类")
private Integer classification;
@Lob
@Column(name = "CONNECTIONS")
@ApiModelProperty("方法组内的连线关系")
private String connections;
}

@ -51,4 +51,8 @@ public class MethodLog extends BaseBean implements Serializable {
@ApiModelProperty("方法所属应用冗余")
@Column(name = "APP_NAME_RDD")
private String appNameRdd;
@ApiModelProperty("区分方法或者脚本,BSP枚举")
@Column(name = "TYPE")
private Integer type;
}

Loading…
Cancel
Save