提交 24899b83 编写于 作者: sq3536's avatar sq3536

新增pg

上级 8511edba
......@@ -11,6 +11,7 @@ public interface ExecResultExMapper extends BaseMapper<EntityObj>{
int replaceBatch(@Param("list") List<ExecResult> var1 , @Param("resultTableName") String tableName);
int replaceBatchByOracle(@Param("list") List<ExecResult> var1 , @Param("resultTableName") String tableName);
int replaceBatchByPG(@Param("list") List<ExecResult> var1 , @Param("resultTableName") String tableName);
int clearBatch(@Param("list")List<ExecResult> var1, @Param("resultTableName") String tableName);
......
......@@ -198,10 +198,10 @@ public class AnalyseEntityServiceImpl extends BaseEntityServiceImpl {
modelObj.set(Tag_EngineId, msg.getEngineId());
modelObj.set("systemid",msg.getSystemid());
if(!StringUtils.isEmpty(msg.getResultDataSource())){
modelObj.set(RuleEngineExService.Setting_ResultDataSource, msg.getResultDataSource());
modelObj.set("resultDataSource", msg.getResultDataSource());
}
if(!StringUtils.isEmpty(msg.getResultTableName())){
modelObj.set(RuleEngineExService.Setting_ResultTableName, msg.getResultTableName());
modelObj.set("resultTableName", msg.getResultTableName());
}
processRule(modelObj, modelObj.getRowKey(),strResId);
ResultsMQMsg resultsMQMsg = new ResultsMQMsg();
......
......@@ -97,17 +97,17 @@ public class AnalyseSqlServiceImpl extends BaseEntityServiceImpl {
result.setDomainsField(DOMAINSFIELD.getValue(String.class, ""));
result.setSystemId(DataObject.getStringValue(param.get("systemid"),null));
Object resultDataSource = ExecResultExService.Default_ResultDataSource;
Object resultTableName = ExecResultExService.Default_ResultTableName;
if(param.containsKey(RuleEngineExService.Setting_ResultDataSource.toUpperCase())){
resultDataSource = param.get(RuleEngineExService.Setting_ResultDataSource);
Object resultDataSource = Default_ResultDataSource;
Object resultTableName = Default_ResultTableName;
if(param.get("resultDataSource")!=null){
resultDataSource = param.get("resultDataSource");
}
if(param.containsKey(RuleEngineExService.Setting_ResultTableName.toUpperCase())){
resultTableName = param.get(RuleEngineExService.Setting_ResultTableName);
if(param.get("resultTableName")!=null){
resultTableName = param.get("resultTableName");
}
result.set(Tag_EngineId,param.get(Tag_EngineId));
result.set(RuleEngineExService.Setting_ResultDataSource, resultDataSource);
result.set(RuleEngineExService.Setting_ResultTableName, resultTableName);
result.set("resultDataSource", resultDataSource);
result.set("resultTableName", resultTableName);
if((!StringUtils.isEmpty(result.getRuleId()))&&(!StringUtils.isEmpty(result.getKeyValueField()))) {
......@@ -209,10 +209,10 @@ public class AnalyseSqlServiceImpl extends BaseEntityServiceImpl {
modelObj.set(Tag_EngineId, msg.getEngineId());
modelObj.set("systemid",msg.getSystemid());
if(!StringUtils.isEmpty(msg.getResultDataSource())){
modelObj.set(RuleEngineExService.Setting_ResultDataSource, msg.getResultDataSource());
modelObj.set("resultDataSource", msg.getResultDataSource());
}
if(!StringUtils.isEmpty(msg.getResultTableName())){
modelObj.set(RuleEngineExService.Setting_ResultTableName, msg.getResultTableName());
modelObj.set("resultTableName", msg.getResultTableName());
}
processRule(modelObj, modelObj.getRowKey(),strResId);
......
......@@ -55,6 +55,11 @@ public class BaseEntityServiceImpl implements BaseEntityService
KieContainer kContainer = ks.getKieClasspathContainer();
}
@Value("${defaultResultDataSource:default}")
protected String Default_ResultDataSource;
@Value("${defaultResultTableName:IBZRULERESULT}")
protected String Default_ResultTableName;
public void saveResult(ModelObj param, String RULEID,String RULECODE, String RULENAME, String RU_EXECRESULTNAME, FieldObj BUSINESSCAT, Integer RETVALUE, FieldObj KEYVALUEFIELD, FieldObj DOMAINSFIELD,FieldObj DIMFIELD,
FieldObj METRICFIELD, FieldObj TIMEFIELD, FieldObj EXT1FIELD, FieldObj EXT2FIELD)
......@@ -121,17 +126,17 @@ public class BaseEntityServiceImpl implements BaseEntityService
}
Object resultDataSource = ExecResultExService.Default_ResultDataSource;
Object resultTableName = ExecResultExService.Default_ResultTableName;
if(param.containsKey(RuleEngineExService.Setting_ResultDataSource.toUpperCase())){
resultDataSource = param.get(RuleEngineExService.Setting_ResultDataSource);
Object resultDataSource = Default_ResultDataSource;
Object resultTableName = Default_ResultTableName;
if(param.get("resultDataSource")!=null){
resultDataSource = param.get("resultDataSource");
}
if(param.containsKey(RuleEngineExService.Setting_ResultTableName.toUpperCase())){
resultTableName = param.get(RuleEngineExService.Setting_ResultTableName);
if(param.get("resultTableName")!=null){
resultTableName = param.get("resultTableName");
}
result.set(Tag_EngineId,param.get(Tag_EngineId));
result.set(RuleEngineExService.Setting_ResultDataSource, resultDataSource);
result.set(RuleEngineExService.Setting_ResultTableName, resultTableName);
result.set("resultDataSource", resultDataSource);
result.set("resultTableName", resultTableName);
if(DIMFIELD.isEmpty())
return;
......@@ -475,10 +480,10 @@ public class BaseEntityServiceImpl implements BaseEntityService
modelObj.set(Tag_EngineId, msg.getEngineId());
modelObj.set("systemid",msg.getSystemid());
if(!StringUtils.isEmpty(msg.getResultDataSource())){
modelObj.set(RuleEngineExService.Setting_ResultDataSource, msg.getResultDataSource());
modelObj.set("resultDataSource", msg.getResultDataSource());
}
if(!StringUtils.isEmpty(msg.getResultTableName())){
modelObj.set(RuleEngineExService.Setting_ResultTableName, msg.getResultTableName());
modelObj.set("resultTableName", msg.getResultTableName());
}
processRule(modelObj, modelObj.getRowKey(),strResId);
......
......@@ -51,6 +51,12 @@ public class DABuildExService extends DABuildServiceImpl {
@Value("${ibiz.rulepath:/app/file/rules/}")
private String rulePath;
@Value("${defaultResultDataSource:default}")
private String Default_ResultDataSource;
@Value("${defaultResultTableName:IBZRULERESULT}")
private String Default_ResultTableName;
@Autowired
protected IExecLogService ruExecLogService;
......@@ -177,12 +183,14 @@ public class DABuildExService extends DABuildServiceImpl {
msg.setEngineId(engineMQMsg.getEngineId());
String resultDataSource = Setting.getValue(et.getExtParams(), "resultDataSource");
String resultTableName = Setting.getValue(et.getExtParams(), "resultTableName");
if(!StringUtils.isEmpty(resultDataSource)){
msg.setResultDataSource(resultDataSource);
if(StringUtils.isEmpty(resultDataSource)){
resultDataSource=Default_ResultDataSource;
}
if(!StringUtils.isEmpty(resultTableName)){
msg.setResultTableName(resultTableName);
if(StringUtils.isEmpty(resultTableName)){
resultTableName=Default_ResultTableName;
}
msg.setResultDataSource(resultDataSource);
msg.setResultTableName(resultTableName);
ExecLog execlog=new ExecLog();
execlog.setId(msg.getId());
......
......@@ -9,6 +9,7 @@ import com.baomidou.dynamic.datasource.DynamicRoutingDataSource;
import com.baomidou.dynamic.datasource.toolkit.DynamicDataSourceContextHolder;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Lazy;
import org.springframework.context.annotation.Primary;
import org.springframework.stereotype.Service;
......@@ -27,8 +28,11 @@ import java.util.*;
@Service("ExecResultExService")
public class ExecResultExService extends ExecResultServiceImpl {
public static final String Default_ResultDataSource = "default";
public static final String Default_ResultTableName = "IBZRULERESULT";
@Value("${defaultResultDataSource:default}")
private String Default_ResultDataSource;
@Value("${defaultResultTableName:IBZRULERESULT}")
private String Default_ResultTableName;
@Autowired
@Lazy
......@@ -163,8 +167,8 @@ public class ExecResultExService extends ExecResultServiceImpl {
*/
private void addExecResult(Map<String, List<ExecResult>> execResultMap, ExecResult execResult) {
Object engineId = execResult.get(BaseEntityServiceImpl.Tag_EngineId);
Object dsName = execResult.get(RuleEngineExService.Setting_ResultDataSource);
Object tabName = execResult.get(RuleEngineExService.Setting_ResultTableName);
Object dsName = execResult.get("resultDataSource");
Object tabName = execResult.get("resultTableName");
String id = String.format("%s|%s|%s",engineId,dsName,tabName);
if (ObjectUtils.isEmpty(engineId)) {
log.error("存储规则结果失败,无法数据[{}]的引擎标识!", execResult.getId());
......
......@@ -45,9 +45,12 @@ public class RuleEngineExService extends RuleEngineServiceImpl {
return com.baomidou.mybatisplus.core.toolkit.ReflectionKit.getSuperClassGenericType(this.getClass().getSuperclass(), 1);
}
public static final String Setting_ResultDataSource = "resultDataSource";
public static final String Setting_ResultTableName = "resultTableName";
@Value("${defaultResultDataSource:default}")
private String Default_ResultDataSource;
@Value("${defaultResultTableName:IBZRULERESULT}")
private String Default_ResultTableName;
@Autowired
private IRuleItemService ruleItemService;
......@@ -138,14 +141,17 @@ public class RuleEngineExService extends RuleEngineServiceImpl {
msg.setBatch(engineMQMsg.getBatch());
msg.setSystemid(et.getSystemId());
msg.setEngineId(engineMQMsg.getEngineId());
String resultDataSource = Setting.getValue(et.getExtParams(), Setting_ResultDataSource);
String resultTableName = Setting.getValue(et.getExtParams(), Setting_ResultTableName);
if(!StringUtils.isEmpty(resultDataSource)){
msg.setResultDataSource(resultDataSource);
String resultDataSource = Setting.getValue(et.getExtParams(), "resultDataSource");
String resultTableName = Setting.getValue(et.getExtParams(), "resultTableName");
if(StringUtils.isEmpty(resultDataSource)){
resultDataSource=Default_ResultDataSource;
}
if(!StringUtils.isEmpty(resultTableName)){
msg.setResultTableName(resultTableName);
if(StringUtils.isEmpty(resultTableName)){
resultTableName=Default_ResultTableName;
}
msg.setResultDataSource(resultDataSource);
msg.setResultTableName(resultTableName);
ExecLog execlog=new ExecLog();
execlog.setId(msg.getId());
execlog.setName(msg.getBatch());
......
......@@ -33,6 +33,20 @@
VALUES (B.ru_execresultid,B.ru_execresultname, B.createdate, B.updatedate, B.ruleid, B.rulename, B.retvalue, B.keyvaluefield,B.dimfield, B.metricfield,B.domainsfield,B.timefield,B.ext1field,B.ext2field, B.businesscat, B.systemId)
</insert>
<insert id="replaceBatchByPG" parameterType="java.util.List" databaseId="postgresql">
INSERT INTO ${resultTableName}
(ru_execresultid,ru_execresultname, createdate, updatedate, ruleid, rulename, retvalue, keyvaluefield,dimfield, metricfield,domainsfield,timefield,ext1field,ext2field, businesscat , systemid )
VALUES
<foreach collection="list" item="item" index="index" separator=",">
(#{item.id}, #{item.name}, now(), now(), #{item.ruleId}, #{item.ruleName}, #{item.retValue}, #{item.keyValueField}, #{item.dimField}, #{item.metricField},
#{item.domainsField},#{item.timeField}, #{item.ext1Field}, #{item.ext2Field},#{item.businessCat},#{item.systemId} )
</foreach>
ON conflict(ru_execresultid) DO UPDATE set
ru_execresultname=excluded.name, updatedate=current_timestamp, ruleid=excluded.ruleId, rulename=excluded.ruleName,
retvalue=excluded.retValue, keyvaluefield=excluded.keyValueField, dimfield=excluded.dimField, metricfield=excluded.metricField,domainsfield=excluded.domainsField,timefield=excluded.timeField,
ext1field=excluded.ext1Field,ext2field=excluded.ext2Field, businesscat=excluded.businessCat,systemid=excluded.systemId
</insert>
<!--t1.BUSINESSCAT, t1.CREATEDATE, t1.DIMFIELD, t1.DOMAINSFIELD, t1.EXT1FIELD, t1.EXT2FIELD, t1.KEYVALUEFIELD, t1.METRICFIELD,
t1.RETVALUE, t1.RULEID, t1.RULENAME, t1.RU_EXECRESULTID, t1.RU_EXECRESULTNAME, t1.SYSTEMID, t1.TIMEFIELD, t1.UPDATEDATE-->
<insert id="replaceBatchByOracle" parameterType="java.util.List">
......@@ -48,6 +62,21 @@
INSERT ( ru_execresultid,ru_execresultname, createdate, updatedate, ruleid, rulename, retvalue, keyvaluefield,dimfield, metricfield,domainsfield,timefield,ext1field,ext2field, businesscat, systemid )
VALUES (B.ru_execresultid,B.ru_execresultname, B.createdate, B.updatedate, B.ruleid, B.rulename, B.retvalue, B.keyvaluefield,B.dimfield, B.metricfield,B.domainsfield,B.timefield,B.ext1field,B.ext2field, B.businesscat, B.systemId)
</insert>
<insert id="replaceBatchByPG" parameterType="java.util.List">
INSERT INTO ${resultTableName}
(ru_execresultid,ru_execresultname, createdate, updatedate, ruleid, rulename, retvalue, keyvaluefield,dimfield, metricfield,domainsfield,timefield,ext1field,ext2field, businesscat , systemid )
VALUES
<foreach collection="list" item="item" index="index" separator=",">
(#{item.id}, #{item.name}, now(), now(), #{item.ruleId}, #{item.ruleName}, #{item.retValue}, #{item.keyValueField}, #{item.dimField}, #{item.metricField},
#{item.domainsField},#{item.timeField}, #{item.ext1Field}, #{item.ext2Field},#{item.businessCat},#{item.systemId} )
</foreach>
ON conflict(ru_execresultid) DO UPDATE set
ru_execresultname=excluded.name, updatedate=current_timestamp, ruleid=excluded.ruleId, rulename=excluded.ruleName,
retvalue=excluded.retValue, keyvaluefield=excluded.keyValueField, dimfield=excluded.dimField, metricfield=excluded.metricField,domainsfield=excluded.domainsField,timefield=excluded.timeField,
ext1field=excluded.ext1Field,ext2field=excluded.ext2Field, businesscat=excluded.businessCat,systemid=excluded.systemId
</insert>
<delete id="clearBatch" parameterType="java.util.List" >
delete from ${resultTableName} where (ru_execresultid) in
......
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册