...
|
...
|
@@ -80,7 +80,7 @@ type ( |
|
|
}
|
|
|
)
|
|
|
|
|
|
func NewFormulasGenerateRequest(table *domain.Table, queryComponents []*domain.QueryComponent) FormulasGenerateRequest {
|
|
|
func NewFormulasGenerateRequest(querySet *domain.QuerySet, table *domain.Table, queryComponents []*domain.QueryComponent) FormulasGenerateRequest {
|
|
|
var formatFormulaName = func(input string) string {
|
|
|
sep := fmt.Sprintf("_c%d", table.Context.CompanyId)
|
|
|
before := strings.Split(input, sep)
|
...
|
...
|
@@ -95,13 +95,13 @@ func NewFormulasGenerateRequest(table *domain.Table, queryComponents []*domain.Q |
|
|
FormulaType: 0,
|
|
|
FormulaConditions: make([]FormulaCondition, 0),
|
|
|
}
|
|
|
if table.TableType == domain.SchemaTable.ToString() {
|
|
|
if querySet.Type == domain.SchemaTable.ToString() {
|
|
|
req.FormulaType = 1
|
|
|
} else if table.TableType == domain.SubProcessTable.ToString() {
|
|
|
} else if querySet.Type == domain.SubProcessTable.ToString() {
|
|
|
req.FormulaType = 2
|
|
|
} else if table.TableType == domain.CalculateTable.ToString() {
|
|
|
} else if querySet.Type == domain.CalculateTable.ToString() {
|
|
|
req.FormulaType = 3
|
|
|
} else if table.TableType == domain.CalculateItem.ToString() {
|
|
|
} else if querySet.Type == domain.CalculateItem.ToString() {
|
|
|
req.FormulaType = 4
|
|
|
}
|
|
|
|
...
|
...
|
@@ -141,17 +141,25 @@ func NewFormulaCalculate(table *domain.Table, queryComponent *domain.QueryCompon |
|
|
if queryComponent.Formula != nil {
|
|
|
formula := queryComponent.Formula
|
|
|
res.DatabaseTableName = formula.TableFields[0].TableSqlName
|
|
|
res.FormulaCalculateFields = append(res.FormulaCalculateFields, &FormulaCalculateField{
|
|
|
DatabaseTableName: res.DatabaseTableName,
|
|
|
FieldSchema: NewFieldSchemaFromField(table.DataFields[0]),
|
|
|
CalculateExpression: formula.ExprSql,
|
|
|
CalculateFieldName: table.DataFields[0].SQLName,
|
|
|
})
|
|
|
for _, f := range queryComponent.Formula.TableFields {
|
|
|
res.FormulaCalculateFields = append(res.FormulaCalculateFields, &FormulaCalculateField{
|
|
|
DatabaseTableName: f.TableSqlName,
|
|
|
FieldSchema: NewFieldSchema(f),
|
|
|
CalculateExpression: formula.ExprSql,
|
|
|
CalculateFieldName: table.DataFields[0].SQLName,
|
|
|
})
|
|
|
}
|
|
|
//res.FormulaCalculateFields = append(res.FormulaCalculateFields, &FormulaCalculateField{
|
|
|
// DatabaseTableName: res.DatabaseTableName,
|
|
|
// FieldSchema: NewFieldSchemaFromField(table.DataFields[0]),
|
|
|
// CalculateExpression: formula.ExprSql,
|
|
|
// CalculateFieldName: table.DataFields[0].SQLName,
|
|
|
//})
|
|
|
}
|
|
|
if queryComponent.Aggregation != nil {
|
|
|
res.DatabaseTableName = queryComponent.MasterTable.SQLName
|
|
|
for _, f := range queryComponent.Aggregation.ValueFields {
|
|
|
tableField, ok := table.MatchField(&domain.Field{Name: f.Field.Name})
|
|
|
tableField, ok := table.MatchField(&domain.Field{Name: f.DisplayName})
|
|
|
if !ok {
|
|
|
continue
|
|
|
}
|
...
|
...
|
@@ -163,7 +171,7 @@ func NewFormulaCalculate(table *domain.Table, queryComponent *domain.QueryCompon |
|
|
})
|
|
|
}
|
|
|
for _, f := range queryComponent.Aggregation.RowFields {
|
|
|
tableField, ok := table.MatchField(&domain.Field{Name: f.Field.Name})
|
|
|
tableField, ok := table.MatchField(&domain.Field{Name: f.DisplayName})
|
|
|
if !ok {
|
|
|
continue
|
|
|
}
|
...
|
...
|
@@ -197,7 +205,11 @@ func NewFormulaSelectCondition(c domain.ConditionExpr) FormulaSelectCondition { |
|
|
res.ConditionRightField.ConditionExpression = " null "
|
|
|
}
|
|
|
if c.OperatorSymbol == "!=" && strings.ToLower(c.FieldRight.ExprSql) == "null" {
|
|
|
res.ConditionOperator = "is not"
|
|
|
res.ConditionOperator = " is not "
|
|
|
res.ConditionRightField.ConditionExpression = "null"
|
|
|
}
|
|
|
if c.OperatorSymbol == "<>" && strings.ToLower(c.FieldRight.ExprSql) == "null" {
|
|
|
res.ConditionOperator = " is not "
|
|
|
res.ConditionRightField.ConditionExpression = "null"
|
|
|
}
|
|
|
return res
|
...
|
...
|
|