浏览代码

修改有色数据同步bug

hongze 3 年之前
父节点
当前提交
10622b3ff8
共有 2 个文件被更改,包括 9 次插入4 次删除
  1. 8 4
      models/data_manage/edb_data_ys.go
  2. 1 0
      services/data/edb_info_sync.go

+ 8 - 4
models/data_manage/edb_data_ys.go

@@ -51,15 +51,15 @@ func ModifyEdbDataSmm(edbCode, dataTime string, value float64) (err error) {
 func RefreshEdbDataByYs(edbInfoId int, edbCode, startDate, endDate string) (err error) {
 	var condition string
 	var pars []interface{}
-	condition += " AND base_from_smm_index_id=? "
-	pars = append(pars, edbInfoId)
+	condition += " AND index_code=? "
+	pars = append(pars, edbCode)
 
-	if startDate!="" {
+	if startDate != "" {
 		condition += " AND data_time>=? "
 		pars = append(pars, startDate)
 	}
 
-	if endDate!="" {
+	if endDate != "" {
 		condition += " AND data_time<=? "
 		pars = append(pars, endDate)
 	}
@@ -82,10 +82,12 @@ func RefreshEdbDataByYs(edbInfoId int, edbCode, startDate, endDate string) (err
 
 	existMap := make(map[string]float64)
 	for _, ev := range existDataList {
+		fmt.Println(ev.DataTime, ev.Value)
 		existMap[ev.DataTime] = ev.Value
 	}
 	ysList := make([]*EdbDataYs, 0)
 	for _, dv := range ysBaseDataAll {
+		fmt.Println("baseDataAll:", dv.DataTime, dv.Value)
 		if existItem, ok := existMap[dv.DataTime]; !ok { //新增
 			dataDate, _ := time.Parse(utils.FormatDate, dv.DataTime)
 			timestamp := dataDate.UnixNano() / 1e6
@@ -101,11 +103,13 @@ func RefreshEdbDataByYs(edbInfoId int, edbCode, startDate, endDate string) (err
 			ysList = append(ysList, item)
 		} else {
 			if dv.Value != existItem { //修改
+				fmt.Println("ModifyEdbDataSmm:", edbCode, dv.DataTime, dv.Value)
 				ModifyEdbDataSmm(edbCode, dv.DataTime, dv.Value)
 			}
 		}
 	}
 	if len(ysList) > 0 {
+		fmt.Println("AddEdbDataSmm")
 		err = AddEdbDataSmm(ysList)
 		if err != nil {
 			return

+ 1 - 0
services/data/edb_info_sync.go

@@ -86,6 +86,7 @@ func SyncSmmDataBase() {
 	var pars []interface{}
 	condition += " AND source=? "
 	pars = append(pars, utils.DATA_SOURCE_YS)
+
 	items, err := data_manage.GetEdbInfoByCondition(condition, pars, 0)
 	if err != nil {
 		return