瀏覽代碼

Merge remote-tracking branch 'origin/dm' into dm

Roc 2 月之前
父節點
當前提交
e95c760369

+ 5 - 1
controllers/data_manage/line_feature/chart_info.go

@@ -559,6 +559,10 @@ func (this *LineFeaturesChartInfoController) MultipleGraphConfigSaveChart() {
 		br.ErrMsg = "获取配置与图表的关联关系失败,ERR:" + err.Error()
 		return
 	}
+	// 兼容gorm
+	if multipleGraphConfigChartMapping != nil && multipleGraphConfigChartMapping.Id <= 0 {
+		multipleGraphConfigChartMapping = nil
+	}
 
 	err = nil
 	var isAdd bool
@@ -573,7 +577,7 @@ func (this *LineFeaturesChartInfoController) MultipleGraphConfigSaveChart() {
 			return
 		}
 		// 说明图还在,没有被删除
-		if chartInfo != nil {
+		if chartInfo != nil && chartInfo.ChartInfoId > 0 {
 			chartInfoId = multipleGraphConfigChartMapping.ChartInfoId
 			req.ChartName = chartInfo.ChartName
 			req.ClassifyId = chartInfo.ChartClassifyId

+ 1 - 1
controllers/data_manage/supply_analysis/variety.go

@@ -151,7 +151,7 @@ func (this *VarietyController) Add() {
 		br.ErrMsg = "添加失败,Err:" + err.Error()
 		return
 	}
-	if item != nil {
+	if item != nil && item.VarietyId > 0 {
 		br.Msg = "添加失败,品种名称不能重复"
 		br.IsSendEmail = false
 		return

+ 8 - 3
controllers/ppt_v2.go

@@ -724,9 +724,14 @@ func (this *PptV2Controller) SaveLog() {
 	// 将更新后的PPT, 置顶
 	pptMap, err := models.GetPptMappingByPptId(int64(req.PptId))
 	if err != nil {
-		br.Msg = `该PPT信息不存在, 保存失败`
-		br.ErrMsg = `该PPT信息不存在, 保存失败, Err` + err.Error()
-		br.IsSendEmail = false
+		if utils.IsErrNoRow(err) {
+			br.Msg = `该PPT信息不存在, 保存失败`
+			br.ErrMsg = `该PPT信息不存在, 保存失败, Err` + err.Error()
+			br.IsSendEmail = false
+			return
+		}
+		br.Msg = "保存草稿失败"
+		br.ErrMsg = fmt.Sprintf("保存草稿失败, %v", err)
 		return
 	}
 	pptMapList, err := models.GetPptMappingListByGroupId(pptMap.GroupId)

+ 1 - 1
controllers/report_approve/report_approve_flow.go

@@ -421,7 +421,7 @@ func (this *ReportApproveFlowController) Edit() {
 			br.ErrMsg = "获取审批流是否已存在失败, Err: " + e.Error()
 			return
 		}
-		if exist != nil {
+		if exist != nil && exist.ReportApproveFlowId > 0 {
 			br.Msg = "该分类已有审批流, 请勿重复添加"
 			return
 		}

+ 4 - 1
controllers/semantic_analysis/sa_compare.go

@@ -695,6 +695,9 @@ func (this *SaCompareController) Search() {
 	var list []*saModel.SaCompare
 	saCompare := new(saModel.SaCompare)
 	existCond := fmt.Sprintf(` AND result_img != ""`)
+	if utils.DbDriverName == utils.DbDriverByDm {
+		existCond = ` AND result_img != ''`
+	}
 	existPars := make([]interface{}, 0)
 	if keyword != "" {
 		existCond += ` AND  ( title LIKE ? )`
@@ -703,7 +706,7 @@ func (this *SaCompareController) Search() {
 	total, list, err = saCompare.GetPageItemsByCondition(startSize, pageSize, existCond, existPars, []string{}, "")
 	if err != nil && !utils.IsErrNoRow(err) {
 		br.Msg = "获取失败"
-		br.ErrMsg = "获取图表信息失败,Err:" + err.Error()
+		br.ErrMsg = fmt.Sprintf("获取语义分析失败, %v", err)
 		return
 	}
 

+ 2 - 5
models/data_manage/supply_analysis/variety_plant.go

@@ -64,8 +64,7 @@ func GetVarietyPlantByIdList(idList []int) (items []*VarietyPlant, err error) {
 		return
 	}
 	sql := `SELECT * FROM variety_plant WHERE variety_plant_id in (` + utils.GetOrmInReplace(num) + `)`
-	err = global.DbMap[utils.DbNameIndex].Raw(sql, idList).Scan(&items).Error
-
+	err = global.DbMap[utils.DbNameIndex].Raw(sql, idList).Find(&items).Error
 	return
 }
 
@@ -119,8 +118,7 @@ type VarietyPlantButton struct {
 // GetAllVarietyPlantByVarietyId 根据品种id获取所有的装置
 func GetAllVarietyPlantByVarietyId(varietyId int) (items []*VarietyPlantItem, err error) {
 	sql := `SELECT * FROM variety_plant a  WHERE variety_id = ? ORDER BY sort ASC, variety_plant_id ASC `
-	err = global.DbMap[utils.DbNameIndex].Raw(sql, varietyId).Scan(&items).Error
-
+	err = global.DbMap[utils.DbNameIndex].Raw(sql, varietyId).Find(&items).Error
 	return
 }
 
@@ -136,7 +134,6 @@ func GetCountVarietyPlantByVarietyId(varietyId int) (total int, err error) {
 func DeleteVarietyPlantById(id int) (err error) {
 	sql := `DELETE FROM variety_plant WHERE variety_plant_id = ?`
 	err = global.DbMap[utils.DbNameIndex].Exec(sql, id).Error
-
 	return
 }
 

+ 1 - 0
models/data_manage/trade_analysis/trade_classify.go

@@ -90,6 +90,7 @@ func (m *BaseFromTradeClassify) GetItemsByCondition(condition string, pars []int
 		order = ` ORDER BY ` + orderRule
 	}
 	sql := fmt.Sprintf(`SELECT %s FROM %s WHERE 1=1 %s %s`, fields, m.TableName(), condition, order)
+	sql = utils.ReplaceDriverKeywords("", sql)
 	err = global.DbMap[utils.DbNameIndex].Raw(sql, pars...).Find(&items).Error
 	return
 }

+ 18 - 2
models/edb_monitor/edb_monitor.go

@@ -3,6 +3,7 @@ package edbmonitor
 import (
 	"eta/eta_api/global"
 	"eta/eta_api/utils"
+	"gorm.io/gorm"
 	"time"
 )
 
@@ -30,6 +31,16 @@ type EdbMonitorInfo struct {
 	ModifyTime           time.Time `description:"修改时间"`
 }
 
+func (m *EdbMonitorInfo) AfterFind(db *gorm.DB) (err error) {
+	m.EdbLatestDate = utils.GormDateStrToDateStr(m.EdbLatestDate)
+	return
+}
+
+func (m *EdbMonitorInfo) ConvertTimeStr() {
+	m.EdbLatestDate = utils.GormDateStrToDateStr(m.EdbLatestDate)
+	return
+}
+
 func (m *EdbMonitorInfo) Insert() (int64, error) {
 	err := global.DbMap[utils.DbNameIndex].Create(m).Error
 	if err != nil {
@@ -84,7 +95,12 @@ func GetEdbMonitorInfoById(id int) (item *EdbMonitorInfo, err error) {
 	o := global.DbMap[utils.DbNameIndex]
 	sql := `SELECT * FROM edb_monitor_info WHERE edb_monitor_id =?`
 	err = o.Raw(sql, id).First(&item).Error
-
+	if err != nil {
+		return
+	}
+	if item != nil {
+		item.ConvertTimeStr()
+	}
 	return
 }
 
@@ -133,7 +149,7 @@ func GetEdbMonitorInfoPageByCondition(condition string, pars []interface{}, star
 func GetEdbMonitorCreateUserId() (userIds []int, err error) {
 	o := global.DbMap[utils.DbNameIndex]
 	sql := `SELECT DISTINCT create_user_id FROM edb_monitor_info`
-	err = o.Raw(sql).Scan(&userIds).Error
+	err = o.Raw(sql).Find(&userIds).Error
 
 	return
 }

+ 1 - 1
models/edb_monitor/edb_monitor_classify.go

@@ -124,7 +124,7 @@ func GetEdbMonitorClassifyById(id int) (item *EdbMonitorClassify, err error) {
 
 func GetEdbMonitorClassifyMaxSortByParentId(parentId int) (sort int, err error) {
 	o := global.DbMap[utils.DbNameIndex]
-	sql := "SELECT MAX(sort) FROM edb_monitor_classify WHERE parent_id =?"
+	sql := "SELECT COALESCE(MAX(sort), 0) FROM edb_monitor_classify WHERE parent_id =?"
 	err = o.Raw(sql, parentId).Scan(&sort).Error
 	return
 }

+ 4 - 0
models/ppt_v2.go

@@ -113,6 +113,10 @@ type PptV2ListResp struct {
 // AddPptV2 新增PPT
 func AddPptV2(item *PptV2) (lastId int64, err error) {
 	err = global.DbMap[utils.DbNameReport].Create(item).Error
+	if err != nil {
+		return
+	}
+	lastId = int64(item.PptId)
 	return
 }
 

+ 1 - 1
services/data/chart_classify.go

@@ -490,7 +490,7 @@ func MoveChartClassify(req data_manage.MoveChartClassifyReq, sysUser *system.Adm
 			err = fmt.Errorf("获取父级分类下的同名分类失败, Err: %s", e.Error())
 			return
 		}
-		if exists != nil {
+		if exists != nil && exists.ChartClassifyId > 0 {
 			errMsg = "移动失败,分类名称已存在"
 			return
 		}

+ 1 - 1
services/edb_monitor/edb_monitor_classify.go

@@ -221,7 +221,7 @@ func MoveEdbMonitorClassify(req request.MoveEdbMonitorClassifyReq) (msg string,
 		err = er
 		return
 	}
-	if exists != nil {
+	if exists != nil && exists.ClassifyId > 0 {
 		msg = "移动失败,分类名称已存在"
 		err = errors.New("classify name repeat")
 		return

+ 1 - 1
services/ppt/ppt_group.go

@@ -185,7 +185,7 @@ func AddGroup(groupName string, adminId int, isShare int8, isSharedAdd int8) (ne
 		err = errors.New("目录查询出错:" + err.Error())
 		return
 	}
-	if item != nil {
+	if item != nil && item.GroupId > 0 {
 		err = errors.New("目录名称已存在,不可重复添加")
 		return
 	}

+ 4 - 5
services/task.go

@@ -2,9 +2,7 @@ package services
 
 import (
 	"eta/eta_api/models"
-	"eta/eta_api/services/binlog"
 	"eta/eta_api/services/data"
-	edbmonitor "eta/eta_api/services/edb_monitor"
 	"eta/eta_api/utils"
 	"fmt"
 	"strings"
@@ -50,15 +48,16 @@ func Task() {
 	// 进行指标替换操作
 	go DealReplaceEdbCache()
 
+	// TODO:监听这里需要找下达梦的方案,主流程先跑起来再处理
 	// 监听binlog
 	if utils.MYSQL_DATA_BINLOG_URL != "" {
-		go binlog.ListenMysql()
+		//go binlog.ListenMysql()
 	}
 
-	go edbmonitor.HandleEdbMonitorEdbInfo()
+	//go edbmonitor.HandleEdbMonitorEdbInfo()
 
 	// 监听数据源binlog写入es
-	go binlog.HandleDataSourceChange2Es()
+	//go binlog.HandleDataSourceChange2Es()
 
 	// TODO:数据修复
 	//FixNewEs()