Changes
parent
055f3fe89a
commit
16cffc6c0b
|
@ -11,73 +11,73 @@ import java.util.Date;
|
|||
@Component
|
||||
public class GenerateConstant {
|
||||
|
||||
// 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.rule.engine.action.ActionDiscard;\n";
|
||||
// public static final String SCOPE_IMPORT = "import com.muyu.rule.engine.scope.DataModelEngine";
|
||||
// public static final String PACKAGE_PATH = "package rule.util;";
|
||||
//
|
||||
// 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(Rule rule, RuleEdition ruleEdition) {
|
||||
// SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss");
|
||||
// String format = simpleDateFormat.format(new Date());
|
||||
// String level = selectType(rule.getRuleType());
|
||||
// return PACKAGE_PATH + "\n" +
|
||||
// ACTION_IMPORT + "\n" +
|
||||
// SCOPE_IMPORT + level + ";\n" +
|
||||
// "\n" +
|
||||
// "/**\n" +
|
||||
// " * @date: " + format + "\n" +
|
||||
// " * @Description: " + ruleEdition.getName() + "_" + ruleEdition.getRuleKind() + "\n" +
|
||||
// " * @Version: 1.0\n" +
|
||||
// " */\n" +
|
||||
// "public class " + getClassName(ruleEdition.getRuleCoding()) + " 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;
|
||||
// }
|
||||
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.rule.engine.action.ActionDiscard;\n";
|
||||
public static final String SCOPE_IMPORT = "import com.muyu.rule.engine.scope.DataModelEngine";
|
||||
public static final String PACKAGE_PATH = "package rule.util;";
|
||||
|
||||
public static String generateConstant(RuleEdition ruleEdition) {
|
||||
String format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date());
|
||||
return "package rule.util;\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(Rule rule, RuleEdition ruleEdition) {
|
||||
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss");
|
||||
String format = simpleDateFormat.format(new Date());
|
||||
String level = selectType(rule.getRuleType());
|
||||
return PACKAGE_PATH + "\n" +
|
||||
ACTION_IMPORT + "\n" +
|
||||
SCOPE_IMPORT + level + ";\n" +
|
||||
"\n" +
|
||||
"/**\n" +
|
||||
" * @Author: " + "Chen" + "\n" +
|
||||
" * @date: " + format + "\n" +
|
||||
" * @Description: " + "\n" +
|
||||
" * @Description: " + ruleEdition.getName() + "_" + ruleEdition.getRuleKind() + "\n" +
|
||||
" * @Version: 1.0\n" +
|
||||
" */\n" +
|
||||
"public class " + ruleEdition.getRuleKind() + "{ \n" +
|
||||
// " @Override\n" +
|
||||
"public class " + getClassName(ruleEdition.getRuleCoding()) + " 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;
|
||||
}
|
||||
|
||||
// public static String generateConstant(RuleEdition ruleEdition) {
|
||||
// String format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date());
|
||||
// return "package rule.util;\n" +
|
||||
// "\n" +
|
||||
// "/**\n" +
|
||||
// " * @Author: " + "Chen" + "\n" +
|
||||
// " * @date: " + format + "\n" +
|
||||
// " * @Description: " + "\n" +
|
||||
// " * @Version: 1.0\n" +
|
||||
// " */\n" +
|
||||
// "public class " + ruleEdition.getRuleKind() + "{ \n" +
|
||||
//// " @Override\n" +
|
||||
// " public void run () {\n" +
|
||||
// " }\n" +
|
||||
// "}";
|
||||
// }
|
||||
|
||||
}
|
||||
|
|
|
@ -57,7 +57,7 @@ public class RuleEditionServiceImpl extends ServiceImpl<RuleEditionMapper, RuleE
|
|||
public RuleEdition generate(RuleEdition ruleEdition) {
|
||||
Rule rule = ruleServiceImpl.getById(ruleEdition.getRuleId());
|
||||
ruleEdition.setRuleKind(rule.getName() + ruleEdition.getRuleCoding());
|
||||
ruleEdition.setRuleEngine(GenerateConstant.generateConstant(ruleEdition));
|
||||
ruleEdition.setRuleEngine(GenerateConstant.generateConstant(rule,ruleEdition));
|
||||
return ruleEdition;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue