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

修改本地模板

上级 d6cd0b2b
...@@ -73,7 +73,6 @@ public class DELogicAspect { ...@@ -73,7 +73,6 @@ public class DELogicAspect {
private static BpmnXMLConverter bpmnXMLConverter = new BpmnXMLConverter(); private static BpmnXMLConverter bpmnXMLConverter = new BpmnXMLConverter();
private final ExpressionParser parser = new SpelExpressionParser(); private final ExpressionParser parser = new SpelExpressionParser();
private ConcurrentMap<String, DELogic> deLogicMap = new ConcurrentHashMap<>(); 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<>(); private static Map<String, Object> validLogic = new HashMap<>();
/** /**
...@@ -158,7 +157,7 @@ public class DELogicAspect { ...@@ -158,7 +157,7 @@ public class DELogicAspect {
private void executeLogic(File bpmnFile, Object entity, String action) { private void executeLogic(File bpmnFile, Object entity, String action) {
log.debug("开始执行实体处理逻辑[{}:{}:{}:{}]", entity.getClass().getSimpleName(), action, bpmnFile.getName(),"本地模式"); log.debug("开始执行实体处理逻辑[{}:{}:{}:{}]", entity.getClass().getSimpleName(), action, bpmnFile.getName(),"本地模式");
String bpmnId = DigestUtils.md5DigestAsHex(bpmnFile.getPath().getBytes()); String bpmnId = DigestUtils.md5DigestAsHex(bpmnFile.getPath().getBytes());
DELogic logic = getDELogic(bpmnFile, entity); DELogic logic = getDELogic(bpmnFile);
if (logic == null) { if (logic == null) {
return; return;
} }
...@@ -243,11 +242,10 @@ public class DELogicAspect { ...@@ -243,11 +242,10 @@ public class DELogicAspect {
* 获取逻辑配置 * 获取逻辑配置
* *
* @param bpmnFile * @param bpmnFile
* @param entity
* @return * @return
*/ */
@SneakyThrows @SneakyThrows
private DELogic getDELogic(File bpmnFile, Object entity) { private DELogic getDELogic(File bpmnFile) {
DELogic logic = null; DELogic logic = null;
XMLStreamReader reader = null; XMLStreamReader reader = null;
InputStream bpmn = null; InputStream bpmn = null;
...@@ -276,11 +274,11 @@ public class DELogicAspect { ...@@ -276,11 +274,11 @@ public class DELogicAspect {
CallActivity subBpmn = (CallActivity) item; CallActivity subBpmn = (CallActivity) item;
String bpmnFileName = subBpmn.getName(); String bpmnFileName = subBpmn.getName();
log.debug("正在加载 BPMN{}", bpmnFileName); log.debug("正在加载 BPMN{}", bpmnFileName);
File subBpmnFile = getSubBpmn(getDEModule(entity), entity.getClass().getSimpleName(), bpmnFileName); File subBpmnFile = getSubBpmn(bpmnFileName);
if (ObjectUtils.isEmpty(subBpmnFile)) { if (ObjectUtils.isEmpty(subBpmnFile)) {
log.debug("BPMN:{},缺少文件:{} ", bpmnFileName, subBpmnFile); log.debug("BPMN:{},缺少文件:{} ", bpmnFileName, subBpmnFile);
} }
DELogic refLogic = getDELogic(subBpmnFile, entity); DELogic refLogic = getDELogic(subBpmnFile);
if (refLogic != null) { if (refLogic != null) {
refLogics.add(refLogic); refLogics.add(refLogic);
if (!ObjectUtils.isEmpty(refLogic.getRefRuleFiles())) { if (!ObjectUtils.isEmpty(refLogic.getRefRuleFiles())) {
...@@ -379,7 +377,7 @@ public class DELogicAspect { ...@@ -379,7 +377,7 @@ public class DELogicAspect {
* @return * @return
*/ */
private File getLocalModel(String entity, String action, LogicExecMode logicExecMode) { 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; String filePath = File.separator + "rules" + File.separator + entity.toLowerCase() + File.separator + action + File.separator + logicName;
URL url = this.getClass().getResource(filePath.replace("\\", "/")); URL url = this.getClass().getResource(filePath.replace("\\", "/"));
return ObjectUtils.isEmpty(url) ? null : new File(url.getPath()); return ObjectUtils.isEmpty(url) ? null : new File(url.getPath());
...@@ -388,12 +386,10 @@ public class DELogicAspect { ...@@ -388,12 +386,10 @@ public class DELogicAspect {
/** /**
* 处理逻辑 bpmn * 处理逻辑 bpmn
* *
* @param module
* @param entity
* @param logicName * @param logicName
* @return * @return
*/ */
private File getSubBpmn(String module, String entity, String logicName) { private File getSubBpmn(String logicName) {
String filePath = String.format("/rules/%s", logicName); String filePath = String.format("/rules/%s", logicName);
return ObjectUtils.isEmpty(this.getClass().getResource(filePath)) ? null : new File(this.getClass().getResource(filePath).getPath()); return ObjectUtils.isEmpty(this.getClass().getResource(filePath)) ? null : new File(this.getClass().getResource(filePath).getPath());
} }
...@@ -405,27 +401,10 @@ public class DELogicAspect { ...@@ -405,27 +401,10 @@ public class DELogicAspect {
* @return * @return
*/ */
private File getDrl(File bpmn) { private File getDrl(File bpmn) {
return new File(bpmn.getPath().replace("RuleFlow.bpmn", "Rule.drl")); if(!bpmn.getName().contains("RuleFlow.bpmn")){
} return new File(bpmn.getPath().replace(".bpmn", ".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");
} }
return strModule; return new File(bpmn.getPath().replace("RuleFlow.bpmn", "Rule.drl"));
} }
/** /**
...@@ -911,7 +890,7 @@ public class DELogicAspect { ...@@ -911,7 +890,7 @@ public class DELogicAspect {
* @return * @return
*/ */
private File getLocalModel(String entity, String action, LogicExecMode logicExecMode) { 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; String filePath = File.separator + "rules" + File.separator + entity.toLowerCase() + File.separator + action + File.separator + logicName;
URL url = this.getClass().getResource(filePath.replace("\\", "/")); URL url = this.getClass().getResource(filePath.replace("\\", "/"));
return ObjectUtils.isEmpty(url) ? null : new File(url.getPath()); return ObjectUtils.isEmpty(url) ? null : new File(url.getPath());
...@@ -927,7 +906,7 @@ public class DELogicAspect { ...@@ -927,7 +906,7 @@ public class DELogicAspect {
* @return * @return
*/ */
private File getRemoteModel(String module, String entity, String action, LogicExecMode logicExecMode) { 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()); 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 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册