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

新增pg

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