|
@@ -433,18 +433,26 @@ func refreshAllCalculateBp(to orm.TxOrmer, edbInfoId, source, subSource int, fro
|
|
|
if _, ok := existMap[existKey]; !ok {
|
|
|
timestamp := needDay.UnixNano() / 1e6
|
|
|
timestampStr := fmt.Sprintf("%d", timestamp)
|
|
|
- valStr := decimal.NewFromFloat(currentItem.Value).String()
|
|
|
+
|
|
|
+ currValDeci := decimal.NewFromFloat(currentItem.Value)
|
|
|
if prevItem != nil && needDayStr != currentItem.DataTime {
|
|
|
- valStr = decimal.NewFromFloat(prevItem.Value).String()
|
|
|
+ currValDeci = decimal.NewFromFloat(prevItem.Value)
|
|
|
}
|
|
|
+ currValStr := currValDeci.String()
|
|
|
tmpExistData, ok2 := existDataMap[needDayStr]
|
|
|
if !ok2 {
|
|
|
- addSql += GetAddSql(edbInfoIdStr, edbCode, needDayStr, timestampStr, valStr)
|
|
|
+ addSql += GetAddSql(edbInfoIdStr, edbCode, needDayStr, timestampStr, currValStr)
|
|
|
isAdd = true
|
|
|
} else {
|
|
|
- //如果对应的值不匹配
|
|
|
- if tmpExistData.Value != valStr {
|
|
|
- err = ModifyEdbDataById(source, subSource, tmpExistData.EdbDataId, valStr)
|
|
|
+ // 已经入库的数据值
|
|
|
+ tmpExistVal, tmpErr := decimal.NewFromString(tmpExistData.Value)
|
|
|
+ if tmpErr != nil {
|
|
|
+ err = tmpErr
|
|
|
+ return
|
|
|
+ }
|
|
|
+ // 如果已经入库的数据值 与 当前计算出来的值 不匹配,那么就去更新
|
|
|
+ if !tmpExistVal.Equal(currValDeci) {
|
|
|
+ err = ModifyEdbDataById(source, subSource, tmpExistData.EdbDataId, currValStr)
|
|
|
if err != nil {
|
|
|
return err
|
|
|
}
|