Browse Source

fix:数据刷新设置,添加是否供应商停更字段返回

Roc 6 months ago
parent
commit
9e081290e6
2 changed files with 36 additions and 10 deletions
  1. 16 5
      models/data_manage/edb_info_relation.go
  2. 20 5
      services/data/edb_info_relation.go

+ 16 - 5
models/data_manage/edb_info_relation.go

@@ -236,6 +236,7 @@ type BaseRelationEdbInfo struct {
 	SysUserRealName string `description:"创建人姓名"`
 	Frequency       string `description:"频度"`
 	IsStop          int    `description:"是否停更:1:停更,0:未停更"`
+	IsSupplierStop  int    `description:"是否供应商停更:1:停更,0:未停更"`
 	RelationNum     int    `description:"引用次数"`
 	RelationTime    string `description:"引用时间"`
 }
@@ -261,11 +262,16 @@ type BaseRelationEdbInfoDetailResp struct {
 }
 
 // 查询指标引用列表
-func GetEdbInfoRelationList(condition string, pars []interface{}, orderBy string, startSize, pageSize int) (total int, items []*BaseRelationEdbInfo, err error) {
+func GetEdbInfoRelationList(condition string, pars []interface{}, addFieldStr, joinTableStr, orderBy string, startSize, pageSize int) (total int, items []*BaseRelationEdbInfo, err error) {
 	o := orm.NewOrmUsingDB("data")
 	// 数量汇总
 	totalSql := ` SELECT count(1) FROM edb_info e LEFT JOIN (
-SELECT count(edb_info_id) as relation_num, edb_info_id, max(relation_time) as relation_time FROM edb_info_relation GROUP BY edb_info_id) r on e.edb_info_id=r.edb_info_id WHERE 1=1 `
+SELECT count(edb_info_id) as relation_num, edb_info_id, max(relation_time) as relation_time FROM edb_info_relation GROUP BY edb_info_id) r on e.edb_info_id=r.edb_info_id  `
+
+	if joinTableStr != "" {
+		totalSql += joinTableStr
+	}
+	totalSql += ` WHERE 1=1 `
 	if condition != "" {
 		totalSql += condition
 	}
@@ -274,10 +280,15 @@ SELECT count(edb_info_id) as relation_num, edb_info_id, max(relation_time) as re
 		return
 	}
 
+	fieldStr := ` e.edb_info_id, e.classify_id,e.edb_code,e.edb_name,e.sys_user_id,e.sys_user_real_name,e.frequency,e.no_update as is_stop, r.relation_num, r.relation_time ` + addFieldStr
 	// 列表数据
-	sql := ` SELECT e.edb_info_id, e.classify_id,e.edb_code,e.edb_name,e.sys_user_id,e.sys_user_real_name,e.frequency,e.no_update as is_stop, r.relation_num, r.relation_time from edb_info e LEFT JOIN (
-SELECT count(edb_info_id) as relation_num, edb_info_id, max(relation_time) as relation_time FROM edb_info_relation GROUP BY edb_info_id) r on e.edb_info_id=r.edb_info_id WHERE 1=1
- `
+	sql := ` SELECT ` + fieldStr + ` from edb_info e LEFT JOIN (
+SELECT count(edb_info_id) as relation_num, edb_info_id, max(relation_time) as relation_time FROM edb_info_relation GROUP BY edb_info_id) r on e.edb_info_id=r.edb_info_id  `
+	if joinTableStr != "" {
+		sql += joinTableStr
+	}
+	sql += ` WHERE 1=1 `
+
 	if condition != "" {
 		sql += condition
 	}

+ 20 - 5
services/data/edb_info_relation.go

@@ -357,12 +357,18 @@ func GetEdbRelationList(source, edbType int, classifyId, sysUserId, frequency, k
 	list = make([]*data_manage.BaseRelationEdbInfo, 0)
 
 	isStop := -1
-	if status == `暂停` {
+	switch status {
+	case `暂停`:
 		isStop = 1
-	} else if status == "启用" {
+	case `启用`:
 		isStop = 0
+	case `供应商停用`:
+		isStop = 3
 	}
 
+	// 关联表语句
+	var addFieldStr, joinTableStr string
+
 	switch source {
 	case utils.DATA_SOURCE_MYSTEEL_CHEMICAL, utils.DATA_SOURCE_WIND:
 		condition += ` AND e.source = ? `
@@ -373,10 +379,19 @@ func GetEdbRelationList(source, edbType int, classifyId, sysUserId, frequency, k
 		condition += ` AND e.edb_type = ? AND e.edb_info_type = 0`
 		pars = append(pars, edbType)
 	}
-
-	if isStop >= 0 {
+	switch isStop {
+	case -1:
+	case 0, 1:
 		condition += " AND e.no_update = ? "
 		pars = append(pars, isStop)
+	case 3:
+		// 供应商停用
+		if source == utils.DATA_SOURCE_MYSTEEL_CHEMICAL {
+			condition += " AND z.is_supplier_stop = ? "
+			pars = append(pars, 1)
+			joinTableStr = ` LEFT JOIN base_from_mysteel_chemical_index z ON e.edb_code = z.index_code `
+			addFieldStr = ` ,z.is_supplier_stop `
+		}
 	}
 
 	if classifyId != `` {
@@ -421,7 +436,7 @@ func GetEdbRelationList(source, edbType int, classifyId, sysUserId, frequency, k
 		sortStr = fmt.Sprintf("%s %s,e.edb_info_id desc ", sortParam, sortType)
 	}
 
-	total, list, err = data_manage.GetEdbInfoRelationList(condition, pars, sortStr, startSize, pageSize)
+	total, list, err = data_manage.GetEdbInfoRelationList(condition, pars, addFieldStr, joinTableStr, sortStr, startSize, pageSize)
 
 	return
 }