73 lines
2.6 KiB
Java
73 lines
2.6 KiB
Java
package com.muyu.context;
|
|
|
|
import com.muyu.common.security.utils.SecurityUtils;
|
|
import com.muyu.domain.EngineMaintenance;
|
|
import com.muyu.domain.EngineVersion;
|
|
import org.springframework.stereotype.Component;
|
|
|
|
import java.text.SimpleDateFormat;
|
|
import java.util.Date;
|
|
|
|
@Component
|
|
public class GenerateConstant {
|
|
|
|
public static void main(String[] args) {
|
|
System.out.println("hello world");
|
|
}
|
|
|
|
public static final String DATA_FIELD = "DataEngineValueActuator";
|
|
public static final String DATA_RECORD = "DataEngineRecordActuator";
|
|
public static final String DATA_SET = "DataEngineSetActuator";
|
|
public static final String ACTION_IMPORT = "import com.muyu.abstracts.DataValue;";
|
|
public static final String SCOPE_IMPORT = "import com.muyu.abstracts.DataEngineValueActuator";
|
|
public static final String PACKAGE_PATH = "package com.muyu.abstracts;\n";
|
|
|
|
|
|
public static String getClassName(String versionCode) {
|
|
String[] splits = versionCode.split("_");
|
|
String className = "";
|
|
for (String split : splits) {
|
|
className += split.substring(0, 1).toUpperCase() + split.substring(1);
|
|
}
|
|
return className;
|
|
}
|
|
|
|
public static String generateConstant(EngineMaintenance ruleData, EngineVersion ruleVersion) {
|
|
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss");
|
|
String format = simpleDateFormat.format(new Date());
|
|
// String level = selectType(ruleData.getScope());
|
|
return PACKAGE_PATH + "\n" +
|
|
ACTION_IMPORT + "\n" +
|
|
// SCOPE_IMPORT + level + ";\n" +
|
|
"\n" +
|
|
"/**\n" +
|
|
" * @Author: " + SecurityUtils.getUsername() + "\n" +
|
|
" * @date: " + format + "\n" +
|
|
" * @Description: " + ruleVersion.getName() + "_" + ruleVersion.getVersionCode() + "\n" +
|
|
" * @Version: 1.0\n" +
|
|
" */\n" +
|
|
"public class " + getClassName(ruleVersion.getVersionCode()) + " extends " + DATA_FIELD + " {\n" +
|
|
" @Override\n" +
|
|
" public void run () {\n" +
|
|
"}\n" +
|
|
"}";
|
|
}
|
|
|
|
// public static String selectType(String level) {
|
|
// String type = "";
|
|
// switch (level) {
|
|
// case "F":
|
|
// type = DATA_FIELD;
|
|
// break;
|
|
// case "R":
|
|
// type = DATA_RECORD;
|
|
// break;
|
|
// case "C":
|
|
// type = DATA_SET;
|
|
// break;
|
|
// }
|
|
// return type;
|
|
// }
|
|
|
|
}
|