提交 ffd33184 编写于 作者: chenxiang@lab.ibiz5.com's avatar chenxiang@lab.ibiz5.com

处理逻辑DEAction\PrepareParam

上级 ecf57fee
......@@ -16,6 +16,7 @@ import net.ibizsys.model.dataentity.ds.IPSDEDataSetGroupParam;
import net.ibizsys.model.dataentity.ds.PSDEDataSetGroupParamImpl;
import net.ibizsys.model.dataentity.logic.IPSDELogic;
import org.springframework.util.Assert;
import org.springframework.util.CollectionUtils;
import org.springframework.util.ObjectUtils;
import org.springframework.util.StringUtils;
......@@ -111,11 +112,9 @@ public class EntityModel extends BaseModel {
return this;
}
private List<LogicModel> logics;
private List<LogicModel> logics = new ArrayList<>();
public EntityModel addLogic(LogicModel logicModel) {
if (fields == null)
fields = new ArrayList<>();
logics.add(logicModel);
return this;
}
......@@ -754,9 +753,13 @@ public class EntityModel extends BaseModel {
}
//处理逻辑
for (IPSDELogic logic : dataEntity.getAllPSDELogics()) {
LogicModel logicModel = new LogicModel(this, logic);
this.addLogic(logicModel);
if (!CollectionUtils.isEmpty(dataEntity.getAllPSDELogics())) {
for (IPSDELogic logic : dataEntity.getAllPSDELogics()) {
if (!logic.isEnableBackend())
continue;
LogicModel logicModel = new LogicModel(this, logic);
this.addLogic(logicModel);
}
}
if (dataEntity.getAllPSDEDataQueries() != null) {
......
package cn.ibizlab.codegen.model;
import net.ibizsys.model.dataentity.IPSDataEntity;
import net.ibizsys.model.dataentity.logic.IPSDELogic;
import net.ibizsys.model.dataentity.service.IPSDEServiceAPIMethod;
import net.ibizsys.model.dataentity.logic.IPSDELogicNode;
import net.ibizsys.model.dataentity.logic.IPSDELogicParam;
import org.springframework.util.CollectionUtils;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
public class LogicModel extends BaseModel {
private EntityModel entity;
private boolean hasStartWF = false;
private List<String> ruleGlobalParams = new ArrayList<>();
public List<String> getRuleGlobalParams() {
return ruleGlobalParams;
}
public LogicModel(EntityModel entityModel, IPSDELogic iPSDELogic) {
this.opt = iPSDELogic;
this.entity = entityModel;
this.setCodeName(iPSDELogic.getCodeName());
this.setName(iPSDELogic.getName());
this.setId(String.format("%1$s-%2$s", entity.getCodeName(), iPSDELogic.getCodeName()));
if (!CollectionUtils.isEmpty(iPSDELogic.getPSDELogicParams())) {
for (IPSDELogicParam iPSDELogicParam : iPSDELogic.getPSDELogicParams()) {
String strParamName = iPSDELogicParam.getCodeName().toLowerCase();
if (iPSDELogicParam.getParamPSDataEntity() != null) {
String strDataType = String.format("%s.core.%s.domain.%s",
entityModel.getSystem().getPackageName(),
iPSDELogicParam.getParamPSDataEntity().getPSSystemModule().getCodeName().toLowerCase(),
iPSDELogicParam.getParamPSDataEntity().getCodeName()
);
ruleGlobalParams.add(String.format("global %s %s;", strDataType, strParamName));
} else {
String strDataType = "java.util.Map";
ruleGlobalParams.add(String.format("global %s %s;", strDataType, strParamName));
}
}
}
if (!CollectionUtils.isEmpty(iPSDELogic.getPSDELogicNodes())) {
Map<String, String> map = new HashMap<>();
for (IPSDELogicNode iPSDELogicNode : iPSDELogic.getPSDELogicNodes()) {
if (iPSDELogicNode.getLogicNodeType().equals("STARTWF")) {
hasStartWF = true;
}
try {
Method method = iPSDELogicNode.getClass().getDeclaredMethod("getDstPSDataEntity");
IPSDataEntity dstPSDataEntity = (IPSDataEntity) method.invoke(iPSDELogicNode);
if (!map.containsKey(dstPSDataEntity.getName())) {
String strDataType = String.format("%s.core.%s.service.I%sService",
entityModel.getSystem().getPackageName(),
dstPSDataEntity.getPSSystemModule().getCodeName().toLowerCase(),
dstPSDataEntity.getCodeName()
);
ruleGlobalParams.add(String.format("global %s %s;", strDataType, String.format("%sservice;",dstPSDataEntity.getCodeName().toLowerCase())));
map.put(dstPSDataEntity.getName(), dstPSDataEntity.getName());
}
} catch (Exception e) {
}
}
}
if (hasStartWF) {
String strDataType = "cn.ibizlab.util.client";
ruleGlobalParams.add(String.format("global %s %s;", strDataType, "wfClient"));
}
if (true) {
String strDataType = String.format("%s.core.%s.service.I%sService",
entityModel.getSystem().getPackageName(),
entityModel.getDataEntity().getPSSystemModule().getCodeName().toLowerCase(),
entityModel.getDataEntity().getCodeName()
);
ruleGlobalParams.add(String.format("global %s %s;", strDataType, String.format("iBzSys%sDefaultService;",entityModel.getCodeName())));
}
ruleGlobalParams.add(String.format("global %s %s;", "cn.ibizlab.util.security.AuthenticationUser", "curuser"));
}
public IPSDELogic getPSDELogic() {
......
......@@ -175,7 +175,7 @@ public class ModelStorage {
}
else if (type.equals(TemplateFileType.entityLogic)) {
getSystemModel().getEntities().forEach(item -> item.getLogics().forEach(logicModel -> {
CliOption opt = newCliOption(TemplateFileType.entityLogic).baseData(item, item.getCodeName())
CliOption opt = newCliOption(TemplateFileType.entityLogic).baseData(logicModel, logicModel.getCodeName())
.set("entities", item.getCodeName());
rt.addOption(opt);
}));
......
{{#if (eq deLogicNode.dstPSDEAction.codeName 'Get')}}
cn.ibizlab.util.helper.CachedBeanCopier.copy({{lowerCase deLogicNode.dstPSDataEntity.codeName}}service.get({{lowerCase deLogicNode.dstPSDELogicParam.codeName}}.get{{deLogicNode.dstPSDataEntity.keyPSDEField.codeName}}()),{{lowerCase deLogicNode.dstPSDELogicParam.codeName}});
{{else}}
{{#if (eq deLogicNode.dstPSDEAction.codeName 'Remove')}}
{{lowerCase deLogicNode.dstPSDataEntity.codeName}}service.remove({{lowerCase deLogicNode.dstPSDELogicParam.codeName}}.get{{deLogicNode.dstPSDataEntity.keyPSDEField.codeName}}());
{{else}}
{{lowerCase deLogicNode.dstPSDataEntity.codeName}}service.{{camelCase deLogicNode.dstPSDEAction.codeName}}({{lowerCase deLogicNode.dstPSDELogicParam.codeName}});
{{/if}}
{{/if}}
{{#each deLogicNode.pSDELogicNodeParams as |nodeParam|}}
{{#if (eq nodeParam.srcValueType "SRCVALUE")}}{{lowerCase nodeParam.dstPSDELogicParam.codeName}}.set("{{lowerCase nodeParam.dstFieldName}}","{{nodeParam.srcValue}}");{{/if}}
{{#if (eq nodeParam.srcValueType "SRCDLPARAM")}}{{lowerCase nodeParam.dstPSDELogicParam.codeName}}.set("{{lowerCase nodeParam.dstFieldName}}",{{lowerCase nodeParam.srcPSDELogicParam.codeName}}.get("{{lowerCase nodeParam.srcFieldName}}"));{{/if}}
{{#if (eq nodeParam.srcValueType "CURTIME")}}{{lowerCase nodeParam.dstPSDELogicParam.codeName}}.set("{{lowerCase nodeParam.dstFieldName}}",(new java.sql.Timestamp(new java.util.Date().getTime()))));{{/if}}
{{#if (eq nodeParam.srcValueType "OPERATOR")}}{{lowerCase nodeParam.dstPSDELogicParam.codeName}}.set("{{lowerCase nodeParam.dstFieldName}}",curuser.getUserid());{{/if}}
{{#if (eq nodeParam.srcValueType "OPERATORNAME")}}{{lowerCase nodeParam.dstPSDELogicParam.codeName}}.set("{{lowerCase nodeParam.dstFieldName}}",curuser.getPersonname());{{/if}}
{{#if (eq nodeParam.srcValueType "CONTEXT")}}{{lowerCase nodeParam.dstPSDELogicParam.codeName}}.set("{{lowerCase nodeParam.dstFieldName}}",default.get("{{lowerCase nodeParam.srcFieldName}}"));{{/if}}
{{#if (eq nodeParam.srcValueType "SESSION")}}{{lowerCase nodeParam.dstPSDELogicParam.codeName}}.set("{{lowerCase nodeParam.dstFieldName}}",curuser.getSessionParams().get("{{lowerCase nodeParam.srcFieldName}}"));{{/if}}
{{#if (eq nodeParam.srcValueType "NULLVALUE")}}{{lowerCase nodeParam.dstPSDELogicParam.codeName}}.set("{{lowerCase nodeParam.dstFieldName}}",null);{{/if}}
{{/each}}
\ No newline at end of file
{{entityLogic.codeName}}
import java.util.Map;
import java.util.HashMap;
import com.alibaba.fastjson.JSONObject;
import org.springframework.util.StringUtils;
import org.springframework.util.ObjectUtils;
import cn.ibizlab.util.errors.BadRequestAlertException;
{{#each entityLogic.ruleGlobalParams as |ruleGlobalParam|}}
{{ruleGlobalParam}}
{{/each}}
{{#each entityLogic.pSDELogicNodes as |deLogicNode|}}
//逻辑处理节点[{{deLogicNode.name}}]
rule "{{lowerCase deLogicNode.codeName}}"
ruleflow-group "{{lowerCase deLogicNode.codeName}}"
when
then
{{#eq deLogicNode.logicNodeType "PREPAREPARAM"}}{{> @macro/logic/drl/PrepareParam.hbs deLogicNode=deLogicNode}}{{/eq}}
{{#eq deLogicNode.logicNodeType "DEACTION"}}{{> @macro/logic/drl/DEAction.hbs deLogicNode=deLogicNode}}{{/eq}}
{{#eq deLogicNode.logicNodeType "RAWSQLCALL"}}{{> @macro/logic/drl/RawSQLCall.hbs deLogicNode=deLogicNode}}{{/eq}}
{{#eq deLogicNode.logicNodeType "RAWSQLANDLOOPCALL"}}{{> @macro/logic/drl/RawSQLAndLoopCall.hbs deLogicNode=deLogicNode}}{{/eq}}
{{#eq deLogicNode.logicNodeType "STARTWF"}}{{> @macro/logic/drl/StartWF.hbs deLogicNode=deLogicNode}}{{/eq}}
{{#each entityLogic.pSDELogicParams as |logicParam|}}
update({{lowerCase logicParam.codeName}});//更新fact中变量值
{{/each}}
end
{{/each}}
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册