|
@@ -234,9 +234,15 @@ func refreshAllCalculateHcz(to orm.TxOrmer, edbInfoId, source int, fromEdbInfo *
|
|
|
existDataList := make([]*EdbData, 0)
|
|
|
dataTableName := GetEdbDataTableName(source)
|
|
|
fmt.Println("dataTableName:", dataTableName)
|
|
|
+
|
|
|
+ var existPars []interface{}
|
|
|
sql := `SELECT * FROM %s WHERE edb_info_id=? `
|
|
|
+ if startDate != "" {
|
|
|
+ sql += " AND data_time>=? "
|
|
|
+ existPars = append(existPars, startDate)
|
|
|
+ }
|
|
|
sql = fmt.Sprintf(sql, dataTableName)
|
|
|
- _, err = to.Raw(sql, edbInfoId).QueryRows(&existDataList)
|
|
|
+ _, err = to.Raw(sql, edbInfoId, existPars).QueryRows(&existDataList)
|
|
|
if err != nil {
|
|
|
return err
|
|
|
}
|
|
@@ -246,7 +252,7 @@ func refreshAllCalculateHcz(to orm.TxOrmer, edbInfoId, source int, fromEdbInfo *
|
|
|
existDataMap[v.DataTime] = v.Value
|
|
|
removeDateMap[v.DataTime] = v.DataTime
|
|
|
}
|
|
|
- fmt.Println("existDataMap:", existDataMap)
|
|
|
+
|
|
|
addSql := ` INSERT INTO edb_data_calculate_hcz(edb_info_id,edb_code,data_time,value,create_time,modify_time,data_timestamp) values `
|
|
|
var isAdd bool
|
|
|
existMap := make(map[string]string)
|
|
@@ -263,6 +269,7 @@ func refreshAllCalculateHcz(to orm.TxOrmer, edbInfoId, source int, fromEdbInfo *
|
|
|
if _, ok := existMap[existKey]; !ok {
|
|
|
|
|
|
currentDate, _ := time.Parse(utils.FormatDate, currentItem.DataTime)
|
|
|
+
|
|
|
timestamp := currentDate.UnixNano() / 1e6
|
|
|
timestampStr := fmt.Sprintf("%d", timestamp)
|
|
|
val := HczDiv(currentItem.Value, preItem.Value)
|
|
@@ -299,6 +306,7 @@ func refreshAllCalculateHcz(to orm.TxOrmer, edbInfoId, source int, fromEdbInfo *
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+
|
|
|
if len(removeDateMap) > 0 {
|
|
|
removeDateList := make([]string, 0)
|
|
|
for k := range removeDateMap {
|