|
@@ -216,150 +216,153 @@ export const IndexDefine = () => {
|
|
|
|
|
|
/** 指标创建表单-提交 */
|
|
|
const onCreatorFinish = useCallback((values)=>{
|
|
|
- const {
|
|
|
- id,type,decimalPlaces,relateDimension,dateDimId,
|
|
|
- measure,operations,sensitiveLevel,filters,formIndex,incrementPeriod,
|
|
|
- invokeMethod, periodId,runCycleCode,measureExpr, way, startTime
|
|
|
- } = values;
|
|
|
- const formIndexObj=JSON.parse(formIndex)
|
|
|
- let drillDownDimensions = [];
|
|
|
- if (relateDimension){
|
|
|
- dateDimId && drillDownDimensions.push({
|
|
|
- dimensionId:dateDimId,
|
|
|
- necessary:false,
|
|
|
- inheritedFromModel:false
|
|
|
- })
|
|
|
- relateDimension.forEach(v=>
|
|
|
- drillDownDimensions.push({
|
|
|
- dimensionId:v,
|
|
|
- necessary:false,
|
|
|
- inheritedFromModel:false
|
|
|
- }))
|
|
|
- }
|
|
|
- const bizCondition = bizConditionToSQL(filters);
|
|
|
- // 部分字段需再次处理
|
|
|
- let params = {
|
|
|
- ...values,
|
|
|
- sensitiveLevel:parseInt(sensitiveLevel),
|
|
|
- typeEnum:TYPE_ENUM.METRIC,
|
|
|
- dataFormat:{
|
|
|
- needMultiply100:false,
|
|
|
- decimalPlaces:decimalPlaces?decimalPlaces:2,
|
|
|
- },
|
|
|
- relateDimension:{
|
|
|
- drillDownDimensions
|
|
|
- },
|
|
|
- metricDefineType:DEFINE_TYPE[type],
|
|
|
- statisticsPeriod:periodId
|
|
|
- }
|
|
|
- // 派生指标
|
|
|
- if (type===FORM_TYPE.DERIVED.value){
|
|
|
- params.metricDefineByMeasureParams={
|
|
|
- measures:[
|
|
|
- {
|
|
|
- agg:operations,
|
|
|
- bizName:formIndexObj.bizName,
|
|
|
- constraint:bizCondition,
|
|
|
- }
|
|
|
- ],
|
|
|
- expr:formIndexObj.expr,
|
|
|
- filterSql:""
|
|
|
+ try {
|
|
|
+ const {
|
|
|
+ id,type,decimalPlaces,relateDimension,dateDimId,
|
|
|
+ measure,operations,sensitiveLevel,filters,formIndex,incrementPeriod,
|
|
|
+ invokeMethod, periodId,runCycleCode,measureExpr, way, startTime
|
|
|
+ } = values;
|
|
|
+ let drillDownDimensions = [];
|
|
|
+ if (relateDimension){
|
|
|
+ dateDimId && drillDownDimensions.push({
|
|
|
+ dimensionId:dateDimId,
|
|
|
+ necessary:false,
|
|
|
+ inheritedFromModel:false
|
|
|
+ })
|
|
|
+ relateDimension.forEach(v=>
|
|
|
+ drillDownDimensions.push({
|
|
|
+ dimensionId:v,
|
|
|
+ necessary:false,
|
|
|
+ inheritedFromModel:false
|
|
|
+ }))
|
|
|
}
|
|
|
- }
|
|
|
- // 派生指标
|
|
|
- if (type!==FORM_TYPE.COMPOSITE.value) {
|
|
|
- params.metricDefineByMetricParams = {}
|
|
|
- }
|
|
|
- // 原子指标
|
|
|
- if (type===FORM_TYPE.ATOMIC.value) {
|
|
|
- if (measureExpr.expr){
|
|
|
- params.metricDefineType='CUSTOM'
|
|
|
- params.metricDefineByMeasureParams = {}
|
|
|
- params.metricDefineByFieldParams = {
|
|
|
- fields:measureExpr.metrics.map(item=>({fieldName:item.bizName,agg:'SUM'})),
|
|
|
- expr:measureExpr.expr,
|
|
|
- filterSql:""
|
|
|
- }
|
|
|
- }else {
|
|
|
+ const bizCondition = bizConditionToSQL(filters);
|
|
|
+ // 部分字段需再次处理
|
|
|
+ let params = {
|
|
|
+ ...values,
|
|
|
+ sensitiveLevel:parseInt(sensitiveLevel),
|
|
|
+ typeEnum:TYPE_ENUM.METRIC,
|
|
|
+ dataFormat:{
|
|
|
+ needMultiply100:false,
|
|
|
+ decimalPlaces:decimalPlaces?decimalPlaces:2,
|
|
|
+ },
|
|
|
+ relateDimension:{
|
|
|
+ drillDownDimensions
|
|
|
+ },
|
|
|
+ metricDefineType:DEFINE_TYPE[type],
|
|
|
+ statisticsPeriod:periodId
|
|
|
+ }
|
|
|
+ // 派生指标
|
|
|
+ if (type===FORM_TYPE.DERIVED.value){
|
|
|
+ const formIndexObj=JSON.parse(formIndex);
|
|
|
params.metricDefineByMeasureParams={
|
|
|
measures:[
|
|
|
{
|
|
|
agg:operations,
|
|
|
- bizName:measure,
|
|
|
- constraint:"",
|
|
|
+ bizName:formIndexObj.bizName,
|
|
|
+ constraint:bizCondition,
|
|
|
}
|
|
|
],
|
|
|
- expr:measure,
|
|
|
+ expr:formIndexObj.expr,
|
|
|
filterSql:""
|
|
|
}
|
|
|
}
|
|
|
- }
|
|
|
+ // 派生指标
|
|
|
+ if (type!==FORM_TYPE.COMPOSITE.value) {
|
|
|
+ params.metricDefineByMetricParams = {}
|
|
|
+ }
|
|
|
+ // 原子指标
|
|
|
+ if (type===FORM_TYPE.ATOMIC.value) {
|
|
|
+ if (measureExpr.expr){
|
|
|
+ params.metricDefineType='CUSTOM'
|
|
|
+ params.metricDefineByMeasureParams = {}
|
|
|
+ params.metricDefineByFieldParams = {
|
|
|
+ fields:measureExpr.metrics.map(item=>({fieldName:item.bizName,agg:'SUM'})),
|
|
|
+ expr:measureExpr.expr,
|
|
|
+ filterSql:""
|
|
|
+ }
|
|
|
+ }else {
|
|
|
+ params.metricDefineByMeasureParams={
|
|
|
+ measures:[
|
|
|
+ {
|
|
|
+ agg:operations,
|
|
|
+ bizName:measure,
|
|
|
+ constraint:"",
|
|
|
+ }
|
|
|
+ ],
|
|
|
+ expr:measure,
|
|
|
+ filterSql:""
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
- // 更新、创建指标
|
|
|
- if (id){
|
|
|
- dispatch(updateMetric({
|
|
|
- params,
|
|
|
- resolve({id}){
|
|
|
- dispatch(getIndexByConditions({
|
|
|
- params:{
|
|
|
- domainIds: [commonRef.current.treeSelect.id],
|
|
|
- current:1,
|
|
|
- pageSize:999
|
|
|
- },
|
|
|
- }))
|
|
|
- dispatch(persistenceConfig({
|
|
|
- params:{
|
|
|
- metricId:id,
|
|
|
- runCycleCode,
|
|
|
- tableName:'index_metric_'+id,
|
|
|
- defaultConfig:JSON.stringify({
|
|
|
- unit:1,
|
|
|
- period:incrementPeriod,
|
|
|
- type:invokeMethod,
|
|
|
- startTime,
|
|
|
- way
|
|
|
- }),
|
|
|
- }
|
|
|
- }))
|
|
|
+ // 更新、创建指标
|
|
|
+ if (id){
|
|
|
+ dispatch(updateMetric({
|
|
|
+ params,
|
|
|
+ resolve({id}){
|
|
|
+ dispatch(getIndexByConditions({
|
|
|
+ params:{
|
|
|
+ domainIds: [commonRef.current.treeSelect.id],
|
|
|
+ current:1,
|
|
|
+ pageSize:999
|
|
|
+ },
|
|
|
+ }))
|
|
|
+ dispatch(persistenceConfig({
|
|
|
+ params:{
|
|
|
+ metricId:id,
|
|
|
+ runCycleCode,
|
|
|
+ tableName:'index_metric_'+id,
|
|
|
+ defaultConfig:JSON.stringify({
|
|
|
+ unit:1,
|
|
|
+ period:incrementPeriod,
|
|
|
+ type:invokeMethod,
|
|
|
+ startTime,
|
|
|
+ way
|
|
|
+ }),
|
|
|
+ }
|
|
|
+ }))
|
|
|
|
|
|
- setOpenCreator(false)
|
|
|
- }
|
|
|
- }))
|
|
|
- }else {
|
|
|
- dispatch(createMetric({
|
|
|
- params,
|
|
|
- resolve({id}){
|
|
|
- dispatch(getIndexByConditions({
|
|
|
- params:{
|
|
|
- domainIds: [commonRef.current.treeSelect.id],
|
|
|
- current:1,
|
|
|
- pageSize:999
|
|
|
- },
|
|
|
- }))
|
|
|
- dispatch(persistenceConfig({
|
|
|
- params:{
|
|
|
- metricId:id,
|
|
|
- runCycleCode,
|
|
|
- tableName:'index_metric_'+id,
|
|
|
- defaultConfig:JSON.stringify({
|
|
|
- metricTypeDefaultConfig:{
|
|
|
- timeDefaultConfig:{
|
|
|
- timeMode:"RECENT",
|
|
|
- unit:1,
|
|
|
- period:incrementPeriod,
|
|
|
- type:invokeMethod,
|
|
|
- startTime,
|
|
|
- way
|
|
|
- }
|
|
|
- },
|
|
|
- }),
|
|
|
- }
|
|
|
- }))
|
|
|
- setOpenCreator(false)
|
|
|
- }
|
|
|
- }))
|
|
|
+ setOpenCreator(false)
|
|
|
+ }
|
|
|
+ }))
|
|
|
+ }else {
|
|
|
+ dispatch(createMetric({
|
|
|
+ params,
|
|
|
+ resolve({id}){
|
|
|
+ dispatch(getIndexByConditions({
|
|
|
+ params:{
|
|
|
+ domainIds: [commonRef.current.treeSelect.id],
|
|
|
+ current:1,
|
|
|
+ pageSize:999
|
|
|
+ },
|
|
|
+ }))
|
|
|
+ dispatch(persistenceConfig({
|
|
|
+ params:{
|
|
|
+ metricId:id,
|
|
|
+ runCycleCode,
|
|
|
+ tableName:'index_metric_'+id,
|
|
|
+ defaultConfig:JSON.stringify({
|
|
|
+ metricTypeDefaultConfig:{
|
|
|
+ timeDefaultConfig:{
|
|
|
+ timeMode:"RECENT",
|
|
|
+ unit:1,
|
|
|
+ period:incrementPeriod,
|
|
|
+ type:invokeMethod,
|
|
|
+ startTime,
|
|
|
+ way
|
|
|
+ }
|
|
|
+ },
|
|
|
+ }),
|
|
|
+ }
|
|
|
+ }))
|
|
|
+ setOpenCreator(false)
|
|
|
+ }
|
|
|
+ }))
|
|
|
+ }
|
|
|
+ }catch (error) {
|
|
|
+ throw error;
|
|
|
}
|
|
|
-
|
|
|
},[]);
|
|
|
|
|
|
/** 双击打开详情 */
|