提交 3b4c447d 编写于 作者: zhouweidong's avatar zhouweidong

处理逻辑优化,补充异常日志输出

上级 ed895851
...@@ -92,12 +92,14 @@ public class DELogicAspect { ...@@ -92,12 +92,14 @@ public class DELogicAspect {
EntityBase entity = null; EntityBase entity = null;
if ("remove".equalsIgnoreCase(action) || "get".equalsIgnoreCase(action)) { if ("remove".equalsIgnoreCase(action) || "get".equalsIgnoreCase(action)) {
entity = getEntity(service.getClass()); entity = getEntity(service.getClass());
String id = DEFieldCacheMap.getDEKeyField(entity.getClass()); if(!ObjectUtils.isEmpty(entity)) {
if(StringUtils.isEmpty(id)) { String id = DEFieldCacheMap.getDEKeyField(entity.getClass());
log.debug("无法获取实体主键属性[{}]",entity.getClass().getSimpleName()); if(StringUtils.isEmpty(id)) {
return point.proceed(); log.debug("无法获取实体主键属性[{}]",entity.getClass().getSimpleName());
return point.proceed();
}
entity.set(id, arg);
} }
entity.set(id, arg);
} else if (arg instanceof EntityBase) { } else if (arg instanceof EntityBase) {
entity = (EntityBase) arg; entity = (EntityBase) arg;
} }
...@@ -201,7 +203,7 @@ public class DELogicAspect { ...@@ -201,7 +203,7 @@ public class DELogicAspect {
KieBuilder kieBuilder = kieServices.newKieBuilder(kieFileSystem).buildAll(); KieBuilder kieBuilder = kieServices.newKieBuilder(kieFileSystem).buildAll();
Results results = kieBuilder.getResults(); Results results = kieBuilder.getResults();
if (results.hasMessages(Message.Level.ERROR)) { if (results.hasMessages(Message.Level.ERROR)) {
throw new BadRequestAlertException(String.format("编译实体处理逻辑 [%s] 发生异常, %s", logic.getName(), results.getMessages()), "LogicAspect", "reloadLogic"); throw new BadRequestAlertException(String.format("编译实体处理逻辑 [%s] 发生异常, %s", logic.getName(), results.getMessages()), "DELogicAspect", "reloadLogic");
} }
KieContainer kieContainer = kieServices.newKieContainer(kieServices.getRepository().getDefaultReleaseId()); KieContainer kieContainer = kieServices.newKieContainer(kieServices.getRepository().getDefaultReleaseId());
logic.setContainer(kieContainer); logic.setContainer(kieContainer);
...@@ -304,6 +306,7 @@ public class DELogicAspect { ...@@ -304,6 +306,7 @@ public class DELogicAspect {
logic.setMd5(getMd5(refFiles)); logic.setMd5(getMd5(refFiles));
} }
} catch (Exception e) { } catch (Exception e) {
log.error("执行处理逻辑失败"+e);
} finally { } finally {
try { try {
if (reader != null) { if (reader != null) {
...@@ -313,6 +316,7 @@ public class DELogicAspect { ...@@ -313,6 +316,7 @@ public class DELogicAspect {
bpmn.close(); bpmn.close();
} }
} catch (Exception e) { } catch (Exception e) {
log.error("执行处理逻辑失败"+e);
} }
} }
return logic; return logic;
...@@ -340,7 +344,8 @@ public class DELogicAspect { ...@@ -340,7 +344,8 @@ public class DELogicAspect {
if(!ObjectUtils.isEmpty(service.getSuperclass()) && !service.getSuperclass().getName().equals(Object.class.getName())) { if(!ObjectUtils.isEmpty(service.getSuperclass()) && !service.getSuperclass().getName().equals(Object.class.getName())) {
return getEntity(service.getSuperclass()); return getEntity(service.getSuperclass());
} }
throw new BadRequestAlertException("获取实体信息失败", "DELogicAspect", "getEntity"); log.error("获取实体信息失败,未能在[{}]中找到参数为实体类对象的行为,如create.update等",service.getSimpleName());
return null;
} }
/** /**
...@@ -361,6 +366,7 @@ public class DELogicAspect { ...@@ -361,6 +366,7 @@ public class DELogicAspect {
buffer.append(strBpmn); buffer.append(strBpmn);
} }
} catch (Exception e) { } catch (Exception e) {
log.error("处理逻辑版本检查失败"+e);
} finally { } finally {
if (bpmnFile != null) { if (bpmnFile != null) {
bpmnFile.close(); bpmnFile.close();
...@@ -373,6 +379,7 @@ public class DELogicAspect { ...@@ -373,6 +379,7 @@ public class DELogicAspect {
return null; return null;
} }
} catch (Exception e) { } catch (Exception e) {
log.error("处理逻辑版本检查失败"+e);
return null; return null;
} }
} }
...@@ -432,6 +439,7 @@ public class DELogicAspect { ...@@ -432,6 +439,7 @@ public class DELogicAspect {
FileUtils.copyToFile(in, bpmn); FileUtils.copyToFile(in, bpmn);
} }
} catch (IOException e) { } catch (IOException e) {
log.error("执行处理逻辑失败,无法获取逻辑文件"+e);
} finally { } finally {
if (in != null) { if (in != null) {
try { try {
...@@ -621,12 +629,14 @@ public class DELogicAspect { ...@@ -621,12 +629,14 @@ public class DELogicAspect {
EntityBase entity = null; EntityBase entity = null;
if ("remove".equalsIgnoreCase(action) || "get".equalsIgnoreCase(action)) { if ("remove".equalsIgnoreCase(action) || "get".equalsIgnoreCase(action)) {
entity = getEntity(service.getClass()); entity = getEntity(service.getClass());
String id = DEFieldCacheMap.getDEKeyField(entity.getClass()); if(!ObjectUtils.isEmpty(entity)) {
if(StringUtils.isEmpty(id)) { String id = DEFieldCacheMap.getDEKeyField(entity.getClass());
log.debug("无法获取实体主键属性[{}]",entity.getClass().getSimpleName()); if(StringUtils.isEmpty(id)) {
return point.proceed(); log.debug("无法获取实体主键属性[{}]",entity.getClass().getSimpleName());
return point.proceed();
}
entity.set(id, arg);
} }
entity.set(id, arg);
} else if (arg instanceof EntityBase) { } else if (arg instanceof EntityBase) {
entity = (EntityBase) arg; entity = (EntityBase) arg;
} }
...@@ -650,7 +660,7 @@ public class DELogicAspect { ...@@ -650,7 +660,7 @@ public class DELogicAspect {
File bpmnFile; File bpmnFile;
if (isDyna) { if (isDyna) {
bpmnFile = getRemoteModel(getDEModule(entity), entity.getClass().getSimpleName(), action, LogicExecMode.BEFORE); bpmnFile = getRemoteModel(getDEModule(entity), entity.getClass().getSimpleName(), action, LogicExecMode.BEFORE);
if (bpmnFile.exists()) { if (bpmnFile != null && bpmnFile.exists()) {
executeLogic(bpmnFile, entity, action, LogicMode.REMOTE); executeLogic(bpmnFile, entity, action, LogicMode.REMOTE);
return; return;
} }
...@@ -671,7 +681,7 @@ public class DELogicAspect { ...@@ -671,7 +681,7 @@ public class DELogicAspect {
File bpmnFile; File bpmnFile;
if (isDyna) { if (isDyna) {
bpmnFile = getRemoteModel(getDEModule(entity), entity.getClass().getSimpleName(), action, LogicExecMode.AFTER); bpmnFile = getRemoteModel(getDEModule(entity), entity.getClass().getSimpleName(), action, LogicExecMode.AFTER);
if (bpmnFile.exists()) { if (bpmnFile != null && bpmnFile.exists()) {
executeLogic(bpmnFile, entity, action, LogicMode.REMOTE); executeLogic(bpmnFile, entity, action, LogicMode.REMOTE);
return; return;
} }
...@@ -692,7 +702,7 @@ public class DELogicAspect { ...@@ -692,7 +702,7 @@ public class DELogicAspect {
File bpmnFile; File bpmnFile;
if (isDyna) { if (isDyna) {
bpmnFile = getRemoteModel(getDEModule(entity), entity.getClass().getSimpleName(), action, LogicExecMode.EXEC); bpmnFile = getRemoteModel(getDEModule(entity), entity.getClass().getSimpleName(), action, LogicExecMode.EXEC);
if (bpmnFile.exists()) { if (bpmnFile != null && bpmnFile.exists()) {
executeLogic(bpmnFile, entity, action, LogicMode.REMOTE); executeLogic(bpmnFile, entity, action, LogicMode.REMOTE);
return; return;
} }
...@@ -751,7 +761,7 @@ public class DELogicAspect { ...@@ -751,7 +761,7 @@ public class DELogicAspect {
KieBuilder kieBuilder = kieServices.newKieBuilder(kieFileSystem).buildAll(); KieBuilder kieBuilder = kieServices.newKieBuilder(kieFileSystem).buildAll();
Results results = kieBuilder.getResults(); Results results = kieBuilder.getResults();
if (results.hasMessages(Message.Level.ERROR)) { if (results.hasMessages(Message.Level.ERROR)) {
throw new BadRequestAlertException(String.format("编译实体处理逻辑 [%s] 发生异常, %s", logic.getName(), results.getMessages()), "LogicAspect", "reloadLogic"); throw new BadRequestAlertException(String.format("编译实体处理逻辑 [%s] 发生异常, %s", logic.getName(), results.getMessages()), "DELogicAspect", "reloadLogic");
} }
KieContainer kieContainer = kieServices.newKieContainer(kieServices.getRepository().getDefaultReleaseId()); KieContainer kieContainer = kieServices.newKieContainer(kieServices.getRepository().getDefaultReleaseId());
logic.setContainer(kieContainer); logic.setContainer(kieContainer);
...@@ -855,6 +865,7 @@ public class DELogicAspect { ...@@ -855,6 +865,7 @@ public class DELogicAspect {
logic.setMd5(getMd5(refFiles)); logic.setMd5(getMd5(refFiles));
} }
} catch (Exception e) { } catch (Exception e) {
log.error("执行处理逻辑失败"+e);
} finally { } finally {
try { try {
if (reader != null) { if (reader != null) {
...@@ -864,6 +875,7 @@ public class DELogicAspect { ...@@ -864,6 +875,7 @@ public class DELogicAspect {
bpmn.close(); bpmn.close();
} }
} catch (Exception e) { } catch (Exception e) {
log.error("执行处理逻辑失败"+e);
} }
} }
return logic; return logic;
...@@ -891,7 +903,8 @@ public class DELogicAspect { ...@@ -891,7 +903,8 @@ public class DELogicAspect {
if(!ObjectUtils.isEmpty(service.getSuperclass()) && !service.getSuperclass().getName().equals(Object.class.getName())) { if(!ObjectUtils.isEmpty(service.getSuperclass()) && !service.getSuperclass().getName().equals(Object.class.getName())) {
return getEntity(service.getSuperclass()); return getEntity(service.getSuperclass());
} }
throw new BadRequestAlertException("获取实体信息失败", "DELogicAspect", "getEntity"); log.error("获取实体信息失败,未能在[{}]中找到参数为实体类对象的行为,如create.update等",service.getSimpleName());
return null;
} }
/** /**
...@@ -912,6 +925,7 @@ public class DELogicAspect { ...@@ -912,6 +925,7 @@ public class DELogicAspect {
buffer.append(strBpmn); buffer.append(strBpmn);
} }
} catch (Exception e) { } catch (Exception e) {
log.error("处理逻辑版本检查失败"+e);
} finally { } finally {
if (bpmnFile != null) { if (bpmnFile != null) {
bpmnFile.close(); bpmnFile.close();
...@@ -924,6 +938,7 @@ public class DELogicAspect { ...@@ -924,6 +938,7 @@ public class DELogicAspect {
return null; return null;
} }
} catch (Exception e) { } catch (Exception e) {
log.error("处理逻辑版本检查失败"+e);
return null; return null;
} }
} }
...@@ -1004,6 +1019,7 @@ public class DELogicAspect { ...@@ -1004,6 +1019,7 @@ public class DELogicAspect {
FileUtils.copyToFile(in, bpmn); FileUtils.copyToFile(in, bpmn);
} }
} catch (IOException e) { } catch (IOException e) {
log.error("执行处理逻辑失败,无法获取逻辑文件"+e);
} finally { } finally {
if (in != null) { if (in != null) {
try { try {
......
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册