提交 f0c6844e 编写于 作者: tangyaolong's avatar tangyaolong

修改本地模板

上级 d6cd0b2b
......@@ -70,10 +70,9 @@ import java.util.regex.Pattern;
@Slf4j
public class DELogicAspect {
private static BpmnXMLConverter bpmnXMLConverter = new BpmnXMLConverter();
private static BpmnXMLConverter bpmnXMLConverter = new BpmnXMLConverter();
private final ExpressionParser parser = new SpelExpressionParser();
private ConcurrentMap<String, DELogic> deLogicMap = new ConcurrentHashMap<>();
private final String DEFAULT_MODULE_PACKAGE = "[\\w+\\.]\\.core.(\\w+)\\.domain";
private static Map<String, Object> validLogic = new HashMap<>();
/**
......@@ -158,7 +157,7 @@ public class DELogicAspect {
private void executeLogic(File bpmnFile, Object entity, String action) {
log.debug("开始执行实体处理逻辑[{}:{}:{}:{}]", entity.getClass().getSimpleName(), action, bpmnFile.getName(),"本地模式");
String bpmnId = DigestUtils.md5DigestAsHex(bpmnFile.getPath().getBytes());
DELogic logic = getDELogic(bpmnFile, entity);
DELogic logic = getDELogic(bpmnFile);
if (logic == null) {
return;
}
......@@ -243,11 +242,10 @@ public class DELogicAspect {
* 获取逻辑配置
*
* @param bpmnFile
* @param entity
* @return
*/
@SneakyThrows
private DELogic getDELogic(File bpmnFile, Object entity) {
private DELogic getDELogic(File bpmnFile) {
DELogic logic = null;
XMLStreamReader reader = null;
InputStream bpmn = null;
......@@ -276,11 +274,11 @@ public class DELogicAspect {
CallActivity subBpmn = (CallActivity) item;
String bpmnFileName = subBpmn.getName();
log.debug("正在加载 BPMN{}", bpmnFileName);
File subBpmnFile = getSubBpmn(getDEModule(entity), entity.getClass().getSimpleName(), bpmnFileName);
File subBpmnFile = getSubBpmn(bpmnFileName);
if (ObjectUtils.isEmpty(subBpmnFile)) {
log.debug("BPMN:{},缺少文件:{} ", bpmnFileName, subBpmnFile);
}
DELogic refLogic = getDELogic(subBpmnFile, entity);
DELogic refLogic = getDELogic(subBpmnFile);
if (refLogic != null) {
refLogics.add(refLogic);
if (!ObjectUtils.isEmpty(refLogic.getRefRuleFiles())) {
......@@ -379,7 +377,7 @@ public class DELogicAspect {
* @return
*/
private File getLocalModel(String entity, String action, LogicExecMode logicExecMode) {
String logicName = String.format("%s.bpmn", logicExecMode.value);
String logicName = String.format("%s.bpmn", logicExecMode.text);
String filePath = File.separator + "rules" + File.separator + entity.toLowerCase() + File.separator + action + File.separator + logicName;
URL url = this.getClass().getResource(filePath.replace("\\", "/"));
return ObjectUtils.isEmpty(url) ? null : new File(url.getPath());
......@@ -388,12 +386,10 @@ public class DELogicAspect {
/**
* 处理逻辑 bpmn
*
* @param module
* @param entity
* @param logicName
* @return
*/
private File getSubBpmn(String module, String entity, String logicName) {
private File getSubBpmn(String logicName) {
String filePath = String.format("/rules/%s", logicName);
return ObjectUtils.isEmpty(this.getClass().getResource(filePath)) ? null : new File(this.getClass().getResource(filePath).getPath());
}
......@@ -405,27 +401,10 @@ public class DELogicAspect {
* @return
*/
private File getDrl(File bpmn) {
return new File(bpmn.getPath().replace("RuleFlow.bpmn", "Rule.drl"));
}
/**
* 获取实体模块
*
* @param entity
* @return
*/
private String getDEModule(Object entity) {
String strModule = null;
String packageName = entity.getClass().getPackage().getName();
Pattern p = Pattern.compile(DEFAULT_MODULE_PACKAGE);
Matcher m = p.matcher(packageName);
while (m.find()) {
strModule = m.group(1);
}
if (StringUtils.isEmpty(strModule)) {
throw new BadRequestAlertException(String.format("无法获取实体[%s]所属模块信息", entity.getClass().getSimpleName()), "LogicAspect", "getDEModule");
if(!bpmn.getName().contains("RuleFlow.bpmn")){
return new File(bpmn.getPath().replace(".bpmn", ".drl"));
}
return strModule;
return new File(bpmn.getPath().replace("RuleFlow.bpmn", "Rule.drl"));
}
/**
......@@ -911,7 +890,7 @@ public class DELogicAspect {
* @return
*/
private File getLocalModel(String entity, String action, LogicExecMode logicExecMode) {
String logicName = String.format("%s.bpmn", logicExecMode.value);
String logicName = String.format("%s.bpmn", logicExecMode.text);
String filePath = File.separator + "rules" + File.separator + entity.toLowerCase() + File.separator + action + File.separator + logicName;
URL url = this.getClass().getResource(filePath.replace("\\", "/"));
return ObjectUtils.isEmpty(url) ? null : new File(url.getPath());
......@@ -927,7 +906,7 @@ public class DELogicAspect {
* @return
*/
private File getRemoteModel(String module, String entity, String action, LogicExecMode logicExecMode) {
String logicName = String.format("psdeaction.json.%s.bpmn", logicExecMode.value);
String logicName = String.format("psdeaction.json.%s.bpmn", logicExecMode.text);
return new File(dynamicPath + File.separator + (systemId + File.separator + dynamicId + File.separator + "psmodules" + File.separator + module + File.separator + "psdataentities" + File.separator + entity + File.separator + "psdeactions" + File.separator + action + File.separator + logicName).toLowerCase());
}
......
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册