|
@@ -28,6 +28,7 @@ func (obj CalculateSum) Add(params AddCalculateBatchParams) (edbInfo *EdbInfo, e
|
|
|
defer func() {
|
|
|
if err != nil {
|
|
|
fmt.Println("CalculateSum.Add,Err:" + err.Error())
|
|
|
+ fmt.Println("CalculateSum.Add,ErrMsg:" + errMsg)
|
|
|
_ = to.Rollback()
|
|
|
} else {
|
|
|
_ = to.Commit()
|
|
@@ -58,6 +59,7 @@ func (obj CalculateSum) Add(params AddCalculateBatchParams) (edbInfo *EdbInfo, e
|
|
|
edbInfo.Extra = req.Extra
|
|
|
newEdbInfoId, tmpErr := to.Insert(edbInfo)
|
|
|
if tmpErr != nil {
|
|
|
+ errMsg = "新增失败"
|
|
|
err = tmpErr
|
|
|
return
|
|
|
}
|
|
@@ -67,9 +69,10 @@ func (obj CalculateSum) Add(params AddCalculateBatchParams) (edbInfo *EdbInfo, e
|
|
|
tagMap := make(map[string]int)
|
|
|
relationEdbInfoList := make([]*EdbInfo, 0)
|
|
|
calculateMappingItemList := make([]*EdbInfoCalculateMapping, 0)
|
|
|
- for _, v := range req.EdbInfoIdArr {
|
|
|
+ for k, v := range req.EdbInfoIdArr {
|
|
|
tmpEdbInfo, e := GetEdbInfoById(v.EdbInfoId)
|
|
|
if e != nil {
|
|
|
+ errMsg = "查不到原指标"
|
|
|
err = e
|
|
|
return
|
|
|
}
|
|
@@ -78,7 +81,7 @@ func (obj CalculateSum) Add(params AddCalculateBatchParams) (edbInfo *EdbInfo, e
|
|
|
calculateMappingItem := new(EdbInfoCalculateMapping)
|
|
|
calculateMappingItem.CreateTime = time.Now()
|
|
|
calculateMappingItem.ModifyTime = time.Now()
|
|
|
- calculateMappingItem.Sort = 1
|
|
|
+ calculateMappingItem.Sort = k
|
|
|
calculateMappingItem.EdbCode = edbCode
|
|
|
calculateMappingItem.EdbInfoId = edbInfo.EdbInfoId
|
|
|
calculateMappingItem.FromEdbInfoId = tmpEdbInfo.EdbInfoId
|
|
@@ -96,6 +99,7 @@ func (obj CalculateSum) Add(params AddCalculateBatchParams) (edbInfo *EdbInfo, e
|
|
|
}
|
|
|
_, err = to.InsertMulti(len(calculateMappingItemList), calculateMappingItemList)
|
|
|
if err != nil {
|
|
|
+ errMsg = "保存失败"
|
|
|
return
|
|
|
}
|
|
|
|
|
@@ -170,9 +174,11 @@ func (obj CalculateSum) Edit(params EditCalculateBatchParams) (err error, errMsg
|
|
|
}
|
|
|
|
|
|
if edbInfoIdStr != oldEdbInfoIdStr { // 不需要重复计算
|
|
|
+ fmt.Printf("edbInfoIdStr:%s,oldEdbInfoIdStr:%s\n", edbInfoIdStr, oldEdbInfoIdStr)
|
|
|
needCalculate = true
|
|
|
}
|
|
|
}
|
|
|
+ fmt.Printf("needCalculate:%v\n", needCalculate)
|
|
|
if !needCalculate {
|
|
|
return
|
|
|
}
|
|
@@ -195,9 +201,10 @@ func (obj CalculateSum) Edit(params EditCalculateBatchParams) (err error, errMsg
|
|
|
tagMap := make(map[string]int)
|
|
|
relationEdbInfoList := make([]*EdbInfo, 0)
|
|
|
calculateMappingItemList := make([]*EdbInfoCalculateMapping, 0)
|
|
|
- for _, v := range req.EdbInfoIdArr {
|
|
|
+ for k, v := range req.EdbInfoIdArr {
|
|
|
tmpEdbInfo, tmpErr := GetEdbInfoById(v.EdbInfoId)
|
|
|
if tmpErr != nil {
|
|
|
+ errMsg = "获取数据失败,GetEdbInfoById:" + tmpErr.Error()
|
|
|
err = tmpErr
|
|
|
return
|
|
|
}
|
|
@@ -206,7 +213,7 @@ func (obj CalculateSum) Edit(params EditCalculateBatchParams) (err error, errMsg
|
|
|
calculateMappingItem := new(EdbInfoCalculateMapping)
|
|
|
calculateMappingItem.CreateTime = time.Now()
|
|
|
calculateMappingItem.ModifyTime = time.Now()
|
|
|
- calculateMappingItem.Sort = 1
|
|
|
+ calculateMappingItem.Sort = k
|
|
|
calculateMappingItem.EdbCode = edbInfo.EdbCode
|
|
|
calculateMappingItem.EdbInfoId = edbInfo.EdbInfoId
|
|
|
calculateMappingItem.FromEdbInfoId = tmpEdbInfo.EdbInfoId
|
|
@@ -384,11 +391,12 @@ func (obj CalculateSum) refresh(to orm.TxOrmer, edbInfoId, source, subSource int
|
|
|
existDataMap := make(map[string]string)
|
|
|
|
|
|
for sk, sv := range saveDataMap {
|
|
|
+ if _, ok := dateMap[sk]; !ok {
|
|
|
+ continue
|
|
|
+ }
|
|
|
// 当空值处理类型选择了不计算时,只要有一个指标在某个日期没有值(即空值),则计算指标在该日期没有值
|
|
|
- if emptyType == 1 {
|
|
|
- if len(sv) != len(edbInfoIdArr) {
|
|
|
- continue
|
|
|
- }
|
|
|
+ if len(sv) != len(edbInfoIdArr) {
|
|
|
+ continue
|
|
|
}
|
|
|
|
|
|
var calVal float64
|