指标添加本地变量

This commit is contained in:
andywang
2022-08-10 11:41:40 +08:00
parent 20ff7a2204
commit f11ba7b1bc
6 changed files with 41 additions and 15 deletions

View File

@@ -36,7 +36,7 @@
<result column="source_type" property="sourceType"/> <result column="source_type" property="sourceType"/>
<result column="mq_source_id" property="mqSourceId"/> <result column="mq_source_id" property="mqSourceId"/>
<result column="interface_parse_field" property="interfaceParseField"/> <result column="interface_parse_field" property="interfaceParseField"/>
<result column="is_local_variable" property="isLocalVariable"/>
<collection property="fieldCondList" ofType="fieldCond" column="id" <collection property="fieldCondList" ofType="fieldCond" column="id"
select="com.fibo.ddp.common.dao.datax.datamanage.FieldCondMapper.getFieldCondList"></collection> select="com.fibo.ddp.common.dao.datax.datamanage.FieldCondMapper.getFieldCondList"></collection>
@@ -64,6 +64,7 @@
,f.dict_variable ,f.dict_variable
,f.mq_source_id ,f.mq_source_id
,f.source_type ,f.source_type
,f.is_local_variable
from t_field f, t_field_user_rel r, t_field_type p, t_user u from t_field f, t_field_user_rel r, t_field_type p, t_user u
where f.id = r.field_id where f.id = r.field_id
and f.field_typeid = p.id and f.field_typeid = p.id
@@ -178,6 +179,7 @@
,f.dict_variable ,f.dict_variable
,f.mq_source_id ,f.mq_source_id
,f.source_type ,f.source_type
,f.is_local_variable
from t_field f,t_field_user_rel r,t_field_type p from t_field f,t_field_user_rel r,t_field_type p
where f.id = r.field_id where f.id = r.field_id
and f.field_typeid = p.id and f.field_typeid = p.id
@@ -217,6 +219,7 @@
,f.dict_variable ,f.dict_variable
,f.mq_source_id ,f.mq_source_id
,f.source_type ,f.source_type
,f.is_local_variable
from t_field f,t_field_user_rel r,t_field_type p from t_field f,t_field_user_rel r,t_field_type p
where f.id = r.field_id where f.id = r.field_id
and f.field_typeid = p.id and f.field_typeid = p.id
@@ -243,6 +246,7 @@
,f.dict_variable ,f.dict_variable
,f.mq_source_id ,f.mq_source_id
,f.source_type ,f.source_type
,f.is_local_variable
from t_field f,t_field_type p from t_field f,t_field_type p
,t_field_user_rel r left join t_engine e on (r.engine_id = e.id) ,t_field_user_rel r left join t_engine e on (r.engine_id = e.id)
where f.id = r.field_id where f.id = r.field_id
@@ -293,6 +297,7 @@
,f.dict_variable ,f.dict_variable
,f.mq_source_id ,f.mq_source_id
,f.source_type ,f.source_type
,f.is_local_variable
from t_field f,t_field_user_rel r from t_field f,t_field_user_rel r
where f.id = r.field_id where f.id = r.field_id
and (f.field_en = #{fieldEn} or f.field_cn = #{fieldCn}) and (f.field_en = #{fieldEn} or f.field_cn = #{fieldCn})
@@ -312,19 +317,19 @@
, value_type, value_scope, is_derivative , value_type, value_scope, is_derivative
, is_output, formula, formula_show, orig_fieldid, used_fieldid , is_output, formula, formula_show, orig_fieldid, used_fieldid
, is_common, author, created, is_use_sql, data_source_id, sql_statement, sql_variable , is_common, author, created, is_use_sql, data_source_id, sql_statement, sql_variable
, is_interface, interface_id, interface_parse_field, json_value, organ_id,dict_variable,source_type,mq_source_id) , is_interface, interface_id, interface_parse_field, json_value, organ_id,dict_variable,source_type,mq_source_id, is_local_variable)
values ( #{fieldEn}, #{fieldCn}, #{fieldTypeId} values ( #{fieldEn}, #{fieldCn}, #{fieldTypeId}
, #{valueType}, #{valueScope}, #{isDerivative} , #{valueType}, #{valueScope}, #{isDerivative}
, #{isOutput}, #{formula}, #{formulaShow}, #{origFieldId}, #{usedFieldId} , #{isOutput}, #{formula}, #{formulaShow}, #{origFieldId}, #{usedFieldId}
, #{isCommon}, #{author}, now(), #{isUseSql}, #{dataSourceId}, #{sqlStatement}, #{sqlVariable} , #{isCommon}, #{author}, now(), #{isUseSql}, #{dataSourceId}, #{sqlStatement}, #{sqlVariable}
, #{isInterface}, #{interfaceId}, #{interfaceParseField}, #{jsonValue}, #{organId},#{dictVariable},#{sourceType},#{mqSourceId}) , #{isInterface}, #{interfaceId}, #{interfaceParseField}, #{jsonValue}, #{organId},#{dictVariable},#{sourceType},#{mqSourceId}, #{isLocalVariable})
</insert> </insert>
<insert id="batchCreateField" parameterType="java.util.List"> <insert id="batchCreateField" parameterType="java.util.List">
insert into t_field ( field_en, field_cn, field_typeid insert into t_field ( field_en, field_cn, field_typeid
, value_type, value_scope, is_derivative , value_type, value_scope, is_derivative
, is_output, formula, formula_show, is_common, author, created, , is_output, formula, formula_show, is_common, author, created,
, is_interface, interface_id, interface_parse_field, json_value,dict_variable,source_type,mq_source_id) , is_interface, interface_id, interface_parse_field, json_value,dict_variable,source_type,mq_source_id,is_local_variable)
values values
<foreach collection="list" item="field" index="index" separator=","> <foreach collection="list" item="field" index="index" separator=",">
( (
@@ -332,7 +337,7 @@
, #{field.valueType}, #{field.valueScope}, #{field.isDerivative} , #{field.valueType}, #{field.valueScope}, #{field.isDerivative}
, #{field.isOutput}, #{field.formula}, #{field.formulaShow}, #{field.isCommon}, #{field.author}, now() , #{field.isOutput}, #{field.formula}, #{field.formulaShow}, #{field.isCommon}, #{field.author}, now()
, #{isInterface}, #{interfaceId}, #{interfaceParseField}, , #{isInterface}, #{interfaceId}, #{interfaceParseField},
#{jsonValue},#{dictVariable},#{sourceType},#{mqSourceId} #{jsonValue},#{dictVariable},#{sourceType},#{mqSourceId},#{isLocalVariable}
) )
</foreach> </foreach>
</insert> </insert>
@@ -347,7 +352,7 @@
#{sqlVariable} #{sqlVariable}
,is_interface = #{isInterface}, interface_id = #{interfaceId}, interface_parse_field = #{interfaceParseField}, ,is_interface = #{isInterface}, interface_id = #{interfaceId}, interface_parse_field = #{interfaceParseField},
json_value = #{jsonValue},dict_variable = #{dictVariable} json_value = #{jsonValue},dict_variable = #{dictVariable}
,source_type = #{sourceType},mq_source_id = #{mqSourceId} ,source_type = #{sourceType},mq_source_id = #{mqSourceId}, is_local_variable = #{isLocalVariable}
where id = #{id} where id = #{id}
<!-- where userId = (select field_id--> <!-- where userId = (select field_id-->
<!-- from t_field_user_rel--> <!-- from t_field_user_rel-->
@@ -379,6 +384,7 @@
,t.dict_variable ,t.dict_variable
,t.source_type ,t.source_type
,t.mq_source_id ,t.mq_source_id
,t.is_local_variable
from t_field t LEFT JOIN t_field_user_rel r on t.id = r.field_id LEFT JOIN t_field_type p on t.field_typeid = from t_field t LEFT JOIN t_field_user_rel r on t.id = r.field_id LEFT JOIN t_field_type p on t.field_typeid =
p.id where r.organ_id = #{organId} and status = 1 p.id where r.organ_id = #{organId} and status = 1
<if test="ids != null and ids !=''"> <if test="ids != null and ids !=''">
@@ -405,7 +411,7 @@
select f.id, f.field_en, f.field_cn, f.field_typeid select f.id, f.field_en, f.field_cn, f.field_typeid
, f.value_type, f.value_scope, f.is_derivative , f.value_type, f.value_scope, f.is_derivative
, f.is_output, f.is_common, f.formula, f.formula_show , f.is_output, f.is_common, f.formula, f.formula_show
, f.orig_fieldid,f.dict_variable ,f.source_type ,f.mq_source_id , f.orig_fieldid,f.dict_variable ,f.source_type ,f.mq_source_id,f.is_local_variable
from t_field f,t_field_user_rel r from t_field f,t_field_user_rel r
where f.id = r.field_id where f.id = r.field_id
and f.field_cn = #{fieldCn} and f.field_cn = #{fieldCn}
@@ -504,7 +510,7 @@
, p.type , p.type
, f.is_use_sql, f.data_source_id, f.sql_statement, f.sql_variable, f.is_interface , f.is_use_sql, f.data_source_id, f.sql_statement, f.sql_variable, f.is_interface
, f.interface_id, f.interface_parse_field, f.json_value, f.dict_variable , f.interface_id, f.interface_parse_field, f.json_value, f.dict_variable
,f.source_type,f.mq_source_id ,f.source_type,f.mq_source_id,f.is_local_variable
from t_field f,t_field_user_rel r,t_field_type p from t_field f,t_field_user_rel r,t_field_type p
where f.id = r.field_id where f.id = r.field_id
and f.field_typeid = p.id and f.field_typeid = p.id
@@ -522,7 +528,7 @@
select f.id, f.field_en , f.field_cn , f.field_typeid select f.id, f.field_en , f.field_cn , f.field_typeid
, f.value_type , f.value_scope , f.is_derivative , f.value_type , f.value_scope , f.is_derivative
, f.is_output , f.is_common , f.formula, f.formula_show, f.dict_variable , f.is_output , f.is_common , f.formula, f.formula_show, f.dict_variable
,f.source_type,f.mq_source_id ,f.source_type,f.mq_source_id,f.is_local_variable
from t_field f,t_field_user_rel r from t_field f,t_field_user_rel r
where f.id = r.field_id where f.id = r.field_id
and f.field_en = #{fieldEn} and f.field_en = #{fieldEn}
@@ -535,7 +541,7 @@
, f.value_type , f.value_scope , f.is_derivative , f.value_type , f.value_scope , f.is_derivative
, f.is_output , f.is_common , f.formula, f.formula_show , f.is_output , f.is_common , f.formula, f.formula_show
, f.orig_fieldid, f.dict_variable , f.orig_fieldid, f.dict_variable
,f.source_type,f.mq_source_id ,f.source_type,f.mq_source_id,f.is_local_variable
from t_field f,t_field_user_rel r from t_field f,t_field_user_rel r
where f.id = r.field_id where f.id = r.field_id
and f.field_cn = #{fieldCn} and f.field_cn = #{fieldCn}
@@ -552,7 +558,7 @@
, p.type , p.type
, f.is_use_sql, f.data_source_id, f.sql_statement, f.sql_variable, f.is_interface , f.is_use_sql, f.data_source_id, f.sql_statement, f.sql_variable, f.is_interface
, f.interface_id, f.interface_parse_field, f.json_value, f.dict_variable , f.interface_id, f.interface_parse_field, f.json_value, f.dict_variable
,f.source_type,f.mq_source_id ,f.source_type,f.mq_source_id,f.is_local_variable
from t_field f,t_field_type p from t_field f,t_field_type p
where f.field_typeid=p.id where f.field_typeid=p.id
and f.field_en in and f.field_en in

View File

@@ -1,5 +1,6 @@
package com.fibo.ddp.common.model.common; package com.fibo.ddp.common.model.common;
import com.baomidou.mybatisplus.annotation.TableField;
import lombok.Data; import lombok.Data;
/** /**
@@ -13,25 +14,30 @@ public class BasePage {
/** /**
* 当前页数 * 当前页数
*/ */
@TableField(exist = false)
private int page; private int page;
/** /**
* 每页显示的行数 * 每页显示的行数
*/ */
@TableField(exist = false)
private int rows; private int rows;
/** /**
* 开始行数 * 开始行数
*/ */
@TableField(exist = false)
private Integer curRow; private Integer curRow;
/** /**
* 结束行数 * 结束行数
*/ */
@TableField(exist = false)
private Integer endRow; private Integer endRow;
/** /**
* 总行数 * 总行数
*/ */
@TableField(exist = false)
private Integer total; private Integer total;
} }

View File

@@ -219,4 +219,9 @@ public class Field extends BasePage implements Serializable {
* 消息队列源id * 消息队列源id
*/ */
private Long mqSourceId; private Long mqSourceId;
/**
* 是否局部变量
*/
private Boolean isLocalVariable;
} }

View File

@@ -40,6 +40,7 @@ public class FieldSaveParam implements Serializable {
private String dictVariable; private String dictVariable;
private Integer sourceType; private Integer sourceType;
private Long mqSourceId; private Long mqSourceId;
private Boolean isLocalVariable;
// //
// public Field toField() { // public Field toField() {

View File

@@ -273,9 +273,9 @@ public class RuleServiceImpl extends ServiceImpl<RuleInfoMapper, RuleInfo> imple
@Override @Override
public List<JSONObject> setComplexRuleOutput(Long versionId, Map<String,Object> temp, Map<String, Object> input, String outType) { public List<JSONObject> setComplexRuleOutput(Long versionId, Map<String,Object> temp, Map<String, Object> input, String outType) {
List<JSONObject> jsonObjectList = outputService.setOutput(new StrategyOutput(versionId, StrategyType.COMPLEX_RULE,outType), temp); List<JSONObject> jsonObjectList = outputService.setOutput(new StrategyOutput(versionId, StrategyType.COMPLEX_RULE,outType), temp);
for (JSONObject jsonObject : jsonObjectList) { // for (JSONObject jsonObject : jsonObjectList) {
input.putAll(jsonObject); // input.putAll(jsonObject);
} // }
return jsonObjectList; return jsonObjectList;
} }

View File

@@ -6,9 +6,11 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.fibo.ddp.common.dao.canal.TableEnum; import com.fibo.ddp.common.dao.canal.TableEnum;
import com.fibo.ddp.common.dao.strategyx.strategyout.StrategyOutputMapper; import com.fibo.ddp.common.dao.strategyx.strategyout.StrategyOutputMapper;
import com.fibo.ddp.common.model.datax.datamanage.Field;
import com.fibo.ddp.common.model.enginex.runner.ExpressionParam; import com.fibo.ddp.common.model.enginex.runner.ExpressionParam;
import com.fibo.ddp.common.model.strategyx.strategyout.OutCondition; import com.fibo.ddp.common.model.strategyx.strategyout.OutCondition;
import com.fibo.ddp.common.model.strategyx.strategyout.StrategyOutput; import com.fibo.ddp.common.model.strategyx.strategyout.StrategyOutput;
import com.fibo.ddp.common.service.datax.datamanage.FieldService;
import com.fibo.ddp.common.service.datax.runner.ExecuteUtils; import com.fibo.ddp.common.service.datax.runner.ExecuteUtils;
import com.fibo.ddp.common.service.redis.RedisManager; import com.fibo.ddp.common.service.redis.RedisManager;
import com.fibo.ddp.common.service.redis.RedisUtils; import com.fibo.ddp.common.service.redis.RedisUtils;
@@ -35,6 +37,9 @@ public class StrategyOutputServiceImpl extends ServiceImpl<StrategyOutputMapper,
@Value("${switch.use.cache}") @Value("${switch.use.cache}")
private String cacheSwitch; private String cacheSwitch;
@Autowired
private FieldService fieldService;
@Transactional @Transactional
@Override @Override
public boolean insertTacticsOutput(Long tacticsId, List<StrategyOutput> list) { public boolean insertTacticsOutput(Long tacticsId, List<StrategyOutput> list) {
@@ -152,7 +157,10 @@ public class StrategyOutputServiceImpl extends ServiceImpl<StrategyOutputMapper,
value = value.toString().substring(1,value.toString().length()-1); value = value.toString().substring(1,value.toString().length()-1);
} }
json.put(fieldEn, value); json.put(fieldEn, value);
Field field = fieldService.queryById(strategyOutput.getFieldId());
if(!field.getIsLocalVariable()){
input.put(fieldEn, value); input.put(fieldEn, value);
}
jsonList.add(json); jsonList.add(json);
} }
} }