提交 0ddb3cad 编写于 作者: sq3536's avatar sq3536

调试

上级 3ea12227
package cn.ibizlab.core.extensions.service;
import cn.ibizlab.core.extensions.domain.BaseRequest;
import cn.ibizlab.core.extensions.util.FreeMakerHelper;
import cn.ibizlab.core.lite.extensions.domain.DataObj;
import cn.ibizlab.core.lite.extensions.domain.EntityObj;
import cn.ibizlab.core.lite.extensions.model.DataModel;
import cn.ibizlab.core.lite.extensions.service.LiteDataService;
import cn.ibizlab.core.lite.extensions.service.LiteModelService;
import cn.ibizlab.core.lite.extensions.util.LiteStorage;
import cn.ibizlab.core.rule.service.impl.RuleItemServiceImpl;
import cn.ibizlab.util.helper.DataObject;
import cn.ibizlab.util.helper.Setting;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import lombok.extern.slf4j.Slf4j;
import cn.ibizlab.core.rule.domain.RuleItem;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.context.annotation.Primary;
......@@ -407,5 +415,92 @@ public class RuleItemExService extends RuleItemServiceImpl {
String staticValue = StringUtils.isEmpty(value)?"":value.replace("\\", "");
return modelset.get("datamodelname")+".$S(\""+staticValue+"\")";
}
@Value("${defaultResultDataSource:default}")
private String Default_ResultDataSource;
@Value("${defaultResultTableName:IBZRULERESULT}")
private String Default_ResultTableName;
@Autowired
@Lazy
private LiteDataService liteDataService;
@Autowired
@Lazy
private BaseEntityService baseEntityService;
@Override
public RuleItem testRule(RuleItem ruleItem) {
//自定义代码
String debugKey= DataObject.getStringValue(ruleItem.get("debug-key"),DataObject.getStringValue(ruleItem.get("debugKey"),""));
if(StringUtils.isEmpty(debugKey))
return ruleItem;
String tag=DataObject.getStringValue(ruleItem.getRuleId(),DataObject.getStringValue(ruleItem.getRuleCode(),""));
this.list(Wrappers.<RuleItem>lambdaQuery().eq(RuleItem::getRuleId,tag).or().eq(RuleItem::getRuleCode,tag))
.forEach(et -> {
if("REP".equals(et.getGroup()))
return ;
BaseRequest msg=new BaseRequest();
msg.setModelId(et.getModelId());
msg.setModel(et.getModelName());
msg.setSystemid(et.getSystemId());
msg.setEngineId("TESTRULE-DEBUG");
String resultDataSource=Default_ResultDataSource;
String resultTableName=Default_ResultTableName;
msg.setResultDataSource(resultDataSource);
msg.setResultTableName(resultTableName);
List<String> rules = new ArrayList<>();
DataModel dataModel=liteModelService.getDataModel(et.getModelId());
HashSet<String> fillpropertys=new HashSet<>();
String path=rulePath + et.getGroup() + File.separator + et.getRuleId() + ".drl";
File file=new File(path);
if(!file.exists())
{
this.buildRuleFile(et);
}
if(file.exists())
{
rules.add(path);
}
if((!StringUtils.isEmpty(et.getCond()))&&et.getCond().startsWith("["))
fillpropertys.addAll(JSON.toJavaObject(JSON.parseArray(et.getCond()),LinkedHashSet.class));
dataModel.getAllProperty().forEach(prop->{
if(fillpropertys.contains(prop.getPropertyName()))
{
DataModel p=prop.getOwnerDataModel().getParentDataModel();
while (p!=null)
{
fillpropertys.add(p.getFactPorperty().getPropertyName());
p=p.getParentDataModel();
}
}
});
msg.setRules(rules);
msg.setFillpropertys(fillpropertys);
List<EntityObj> entityObjs=new ArrayList<>();
for(String key:debugKey.split(";|,"))
{
EntityObj entityObj=new EntityObj();
entityObj.put(dataModel.getFactEntityModel().getKeyField().getColumnName().toUpperCase(),key);
entityObjs.add(entityObj);
}
msg.setDatas(liteDataService.getModelObjs(msg.getModelId(),msg.getFillpropertys(),entityObjs));
baseEntityService.processAll(msg);
});
return ruleItem;
}
}
......@@ -16,6 +16,8 @@ import cn.ibizlab.core.lite.extensions.service.LiteModelService;
import cn.ibizlab.core.lite.filter.MetaFieldSearchContext;
import cn.ibizlab.core.lite.service.IMetaEntityService;
import cn.ibizlab.core.lite.service.IMetaFieldService;
import cn.ibizlab.core.rule.domain.RuleItem;
import cn.ibizlab.core.rule.service.IRuleItemService;
import cn.ibizlab.util.dict.CodeItem;
import cn.ibizlab.util.dict.CodeList;
import cn.ibizlab.util.dict.Option;
......@@ -45,7 +47,8 @@ import java.util.Map;
@Api(tags = {"接口" })
@RestController("api-litecore")
@RequestMapping("")
public class DstCoreResource {
public class DstCoreResource
{
@Autowired
private LiteModelService liteModelService;
......@@ -53,6 +56,21 @@ public class DstCoreResource {
@Autowired
private LiteDataService liteDataService;
@Autowired
private IRuleItemService ruleItemService;
@RequestMapping(method = RequestMethod.GET, value = {
"/dst/test/{rulecode}/{key}" })
public ResponseEntity<Boolean> testRule(@PathVariable("rulecode") String rulecode,@PathVariable("key") String key)
{
RuleItem ruleItem=new RuleItem();
ruleItem.setRuleCode(rulecode);
ruleItem.set("debugkey",key);
ruleItemService.testRule(ruleItem);
return ResponseEntity.status(HttpStatus.OK).body(true);
}
@RequestMapping(method = RequestMethod.GET, value = {"/dst/datamodels/{modelid}/data/{key}","/lite/datamodels/{modelid}/data/{key}"})
public ResponseEntity<ModelObj> getModelObj(@PathVariable(name="modelid",required = false) String modelid,@PathVariable(name="key",required = false) String key)
......
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册