|
@@ -2,6 +2,7 @@ package excel
|
|
|
|
|
|
import (
|
|
|
"eta/eta_api/utils"
|
|
|
+ "fmt"
|
|
|
"github.com/beego/beego/v2/client/orm"
|
|
|
"time"
|
|
|
)
|
|
@@ -110,3 +111,32 @@ func DeleteCustomAnalysisExcelEdbMappingByEdbInfoId(excelInfoId int) (err error)
|
|
|
|
|
|
return
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
+func GetExcelEdbMappingItemByExcelInfoIdOrKeyword(excelInfoId int, keyword string) (items []*ExcelEdbMappingItem, err error) {
|
|
|
+ o := orm.NewOrmUsingDB("data")
|
|
|
+ cond := `b.excel_info_id = ?`
|
|
|
+ pars := make([]interface{}, 0)
|
|
|
+ pars = append(pars, excelInfoId)
|
|
|
+ if keyword != "" {
|
|
|
+ cond += ` AND (a.edb_code LIKE ? OR a.edb_name LIKE ?)`
|
|
|
+ pars = append(pars, keyword, keyword)
|
|
|
+ }
|
|
|
+ sql := fmt.Sprintf(`SELECT
|
|
|
+ a.edb_info_id,
|
|
|
+ a.unique_code,
|
|
|
+ a.edb_name,
|
|
|
+ a.classify_id,
|
|
|
+ a.frequency,
|
|
|
+ a.unit,
|
|
|
+ calculate_formula
|
|
|
+ FROM
|
|
|
+ edb_info AS a
|
|
|
+ JOIN excel_edb_mapping AS b ON a.edb_info_id = b.edb_info_id
|
|
|
+ WHERE
|
|
|
+ %s
|
|
|
+ ORDER BY
|
|
|
+ b.excel_edb_mapping_id ASC`, cond)
|
|
|
+ _, err = o.Raw(sql, pars).QueryRows(&items)
|
|
|
+ return
|
|
|
+}
|