|
@@ -14,22 +14,14 @@ import (
|
|
|
"github.com/shopspring/decimal"
|
|
|
)
|
|
|
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
func EdbInfoRefreshAllFromBaseBak(edbInfoIdList []int, refreshAll bool) (err error, errmsg string) {
|
|
|
defer func() {
|
|
|
if err != nil {
|
|
|
fmt.Println("EdbInfoRefreshAllFromBaseV2 Err:" + err.Error() + ";errmsg:" + errmsg)
|
|
|
go alarm_msg.SendAlarmMsg("EdbInfoRefreshFromBaseV2,Err"+err.Error()+";errMsg:"+errmsg, 3)
|
|
|
-
|
|
|
}
|
|
|
}()
|
|
|
|
|
|
-
|
|
|
newBaseEdbInfoArr, newBasePredictEdbInfoArr, newCalculateMap, newPredictCalculateMap, calculateArr, predictCalculateArr, err, errmsg := getRefreshEdbInfoListByIds(edbInfoIdList)
|
|
|
if err != nil {
|
|
|
return
|
|
@@ -37,11 +29,7 @@ func EdbInfoRefreshAllFromBaseBak(edbInfoIdList []int, refreshAll bool) (err err
|
|
|
|
|
|
var startDate string
|
|
|
for _, bv := range newBaseEdbInfoArr {
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
|
|
|
-
|
|
|
startDate = utils.BaseEdbRefreshStartDate
|
|
|
if !refreshAll {
|
|
|
sDate := bv.EndDate
|
|
@@ -86,23 +74,9 @@ func EdbInfoRefreshAllFromBaseBak(edbInfoIdList []int, refreshAll bool) (err err
|
|
|
return
|
|
|
}
|
|
|
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
fmt.Println("end newBaseEdbInfoArr:", bv, time.Now())
|
|
|
}
|
|
|
|
|
|
-
|
|
|
for _, v := range calculateArr {
|
|
|
edbInfo := newCalculateMap[v]
|
|
|
if edbInfo == nil {
|
|
@@ -160,7 +134,6 @@ func EdbInfoRefreshAllFromBaseBak(edbInfoIdList []int, refreshAll bool) (err err
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-
|
|
|
for _, v := range predictCalculateArr {
|
|
|
edbInfo := newPredictCalculateMap[v]
|
|
|
if edbInfo == nil {
|
|
@@ -218,7 +191,6 @@ func EdbInfoRefreshAllFromBaseBak(edbInfoIdList []int, refreshAll bool) (err err
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-
|
|
|
{
|
|
|
predictEdbInfoIdList := make([]int, 0)
|
|
|
for _, v := range newBasePredictEdbInfoArr {
|
|
@@ -249,7 +221,6 @@ func EdbInfoRefreshAllFromBaseBak(edbInfoIdList []int, refreshAll bool) (err err
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-
|
|
|
for _, v := range predictCalculateArr {
|
|
|
edbInfo := newPredictCalculateMap[v]
|
|
|
if edbInfo == nil {
|
|
@@ -309,14 +280,12 @@ func EdbInfoRefreshAllFromBaseBak(edbInfoIdList []int, refreshAll bool) (err err
|
|
|
return
|
|
|
}
|
|
|
|
|
|
-
|
|
|
func getRefreshEdbInfoListByIds(edbInfoIdList []int) (newBaseEdbInfoArr, newBasePredictEdbInfoArr []*data_manage.EdbInfo, newCalculateMap, newPredictCalculateMap map[int]*data_manage.EdbInfo, calculateArr, predictCalculateArr []int, err error, errMsg string) {
|
|
|
calculateList, err := data_manage.GetEdbInfoAllCalculateByEdbInfoIdList(edbInfoIdList)
|
|
|
if err != nil && !utils.IsErrNoRow(err) {
|
|
|
err = errors.New("GetEdbInfoAllCalculate Err:" + err.Error())
|
|
|
return
|
|
|
}
|
|
|
-
|
|
|
edbInfoList, err := data_manage.GetEdbInfoByIdList(edbInfoIdList)
|
|
|
if err != nil {
|
|
|
err = errors.New("GetEdbInfoAllCalGetEdbInfoByIdr:" + err.Error())
|
|
@@ -346,7 +315,6 @@ func getRefreshEdbInfoListByIds(edbInfoIdList []int) (newBaseEdbInfoArr, newBase
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-
|
|
|
for _, v := range calculateList {
|
|
|
getBaseEdbInfoArr, getCalculateInfoArr, tmpErr := data_manage.GetRefreshEdbInfoFromBase(v.EdbInfoId, v.Source)
|
|
|
if tmpErr != nil {
|
|
@@ -369,7 +337,6 @@ func getRefreshEdbInfoListByIds(edbInfoIdList []int) (newBaseEdbInfoArr, newBase
|
|
|
case 0:
|
|
|
calculateInfoArr = append(calculateInfoArr, tmpEdbInfo)
|
|
|
case 1:
|
|
|
-
|
|
|
if tmpEdbInfo.EdbType == 1 {
|
|
|
basePredictEdbInfoArr = append(basePredictEdbInfoArr, tmpEdbInfo)
|
|
|
} else {
|
|
@@ -389,7 +356,6 @@ func getRefreshEdbInfoListByIds(edbInfoIdList []int) (newBaseEdbInfoArr, newBase
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-
|
|
|
for _, v := range predictCalculateInfoArr {
|
|
|
getBaseEdbInfoArr, getCalculateInfoArr, tmpErr := data_manage.GetRefreshEdbInfoFromBase(v.EdbInfoId, v.Source)
|
|
|
if tmpErr != nil {
|
|
@@ -408,7 +374,6 @@ func getRefreshEdbInfoListByIds(edbInfoIdList []int) (newBaseEdbInfoArr, newBase
|
|
|
} else {
|
|
|
predictCalculateInfoArr = append(predictCalculateInfoArr, tmpEdbInfo)
|
|
|
}
|
|
|
-
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -422,7 +387,6 @@ func getRefreshEdbInfoListByIds(edbInfoIdList []int) (newBaseEdbInfoArr, newBase
|
|
|
} else {
|
|
|
predictCalculateInfoArr = append(predictCalculateInfoArr, tmpEdbInfo)
|
|
|
}
|
|
|
-
|
|
|
}
|
|
|
}
|
|
|
switch v.EdbInfoType {
|
|
@@ -437,7 +401,6 @@ func getRefreshEdbInfoListByIds(edbInfoIdList []int) (newBaseEdbInfoArr, newBase
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-
|
|
|
newCalculateMap = make(map[int]*data_manage.EdbInfo)
|
|
|
for _, v := range calculateInfoArr {
|
|
|
if _, ok := newCalculateMap[v.EdbInfoId]; !ok {
|
|
@@ -446,7 +409,6 @@ func getRefreshEdbInfoListByIds(edbInfoIdList []int) (newBaseEdbInfoArr, newBase
|
|
|
newCalculateMap[v.EdbInfoId] = v
|
|
|
}
|
|
|
|
|
|
-
|
|
|
if len(basePredictEdbInfoArr) > 0 {
|
|
|
basePredictEdbInfoIdList := make([]int, 0)
|
|
|
for _, v := range basePredictEdbInfoArr {
|
|
@@ -464,14 +426,12 @@ func getRefreshEdbInfoListByIds(edbInfoIdList []int) (newBaseEdbInfoArr, newBase
|
|
|
case 1:
|
|
|
baseEdbInfoArr = append(baseEdbInfoArr, v)
|
|
|
case 2:
|
|
|
-
|
|
|
if _, ok := newCalculateMap[v.EdbInfoId]; !ok {
|
|
|
tmpCalculateList = append(tmpCalculateList, v)
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-
|
|
|
for _, v := range tmpCalculateList {
|
|
|
getBaseEdbInfoArr, getCalculateInfoArr, tmpErr := data_manage.GetRefreshEdbInfoFromBase(v.EdbInfoId, v.Source)
|
|
|
if tmpErr != nil {
|
|
@@ -481,7 +441,6 @@ func getRefreshEdbInfoListByIds(edbInfoIdList []int) (newBaseEdbInfoArr, newBase
|
|
|
return
|
|
|
}
|
|
|
|
|
|
-
|
|
|
for _, tmpEdbInfo := range getBaseEdbInfoArr {
|
|
|
switch tmpEdbInfo.EdbInfoType {
|
|
|
case 0:
|
|
@@ -491,7 +450,6 @@ func getRefreshEdbInfoListByIds(edbInfoIdList []int) (newBaseEdbInfoArr, newBase
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-
|
|
|
for _, tmpEdbInfo := range getCalculateInfoArr {
|
|
|
switch tmpEdbInfo.EdbInfoType {
|
|
|
case 0:
|
|
@@ -516,7 +474,6 @@ func getRefreshEdbInfoListByIds(edbInfoIdList []int) (newBaseEdbInfoArr, newBase
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-
|
|
|
for _, v := range calculateInfoArr {
|
|
|
if _, ok := newCalculateMap[v.EdbInfoId]; !ok {
|
|
|
calculateArr = append(calculateArr, v.EdbInfoId)
|
|
@@ -525,7 +482,6 @@ func getRefreshEdbInfoListByIds(edbInfoIdList []int) (newBaseEdbInfoArr, newBase
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-
|
|
|
newBaseEdbInfoArr = make([]*data_manage.EdbInfo, 0)
|
|
|
baseMap := make(map[int]int)
|
|
|
for _, v := range baseEdbInfoArr {
|
|
@@ -535,10 +491,8 @@ func getRefreshEdbInfoListByIds(edbInfoIdList []int) (newBaseEdbInfoArr, newBase
|
|
|
baseMap[v.EdbInfoId] = v.EdbInfoId
|
|
|
}
|
|
|
|
|
|
-
|
|
|
sort.Ints(calculateArr)
|
|
|
|
|
|
-
|
|
|
newBasePredictEdbInfoArr = make([]*data_manage.EdbInfo, 0)
|
|
|
basePredictMap := make(map[int]int)
|
|
|
for _, v := range basePredictEdbInfoArr {
|
|
@@ -548,7 +502,6 @@ func getRefreshEdbInfoListByIds(edbInfoIdList []int) (newBaseEdbInfoArr, newBase
|
|
|
basePredictMap[v.EdbInfoId] = v.EdbInfoId
|
|
|
}
|
|
|
|
|
|
-
|
|
|
newPredictCalculateMap = make(map[int]*data_manage.EdbInfo)
|
|
|
for _, v := range predictCalculateInfoArr {
|
|
|
if _, ok := newPredictCalculateMap[v.EdbInfoId]; !ok {
|
|
@@ -556,21 +509,17 @@ func getRefreshEdbInfoListByIds(edbInfoIdList []int) (newBaseEdbInfoArr, newBase
|
|
|
}
|
|
|
newPredictCalculateMap[v.EdbInfoId] = v
|
|
|
}
|
|
|
-
|
|
|
sort.Ints(predictCalculateArr)
|
|
|
|
|
|
return
|
|
|
}
|
|
|
|
|
|
-
|
|
|
func GetEdbSourceByEdbInfoIdList(chartEdbInfoMappingList []*models.ChartEdbInfoMapping) (sourceNameList, sourceNameEnList []string) {
|
|
|
sourceNameList = make([]string, 0)
|
|
|
sourceNameEnList = make([]string, 0)
|
|
|
sourceMap := make(map[int]string)
|
|
|
for _, v := range chartEdbInfoMappingList {
|
|
|
-
|
|
|
if v.EdbType == 2 || v.EdbInfoCategoryType == 1 {
|
|
|
-
|
|
|
baseEdbInfoArr, _, _ := data_manage.GetRefreshEdbInfoFromBase(v.EdbInfoId, v.Source)
|
|
|
for _, baseEdbInfo := range baseEdbInfoArr {
|
|
|
if baseEdbInfo.EdbInfoType == 0 {
|
|
@@ -594,10 +543,7 @@ func GetEdbSourceByEdbInfoIdList(chartEdbInfoMappingList []*models.ChartEdbInfoM
|
|
|
}
|
|
|
sourceNameEnList = append(sourceNameEnList, sourceNameEn)
|
|
|
}
|
|
|
-
|
|
|
-
|
|
|
|
|
|
-
|
|
|
conf, e := models.GetBusinessConf()
|
|
|
if e != nil {
|
|
|
return
|
|
@@ -609,38 +555,19 @@ func GetEdbSourceByEdbInfoIdList(chartEdbInfoMappingList []*models.ChartEdbInfoM
|
|
|
return
|
|
|
}
|
|
|
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
func edbInfoRefreshAll(refreshAll bool, newBaseEdbInfoArr, newBasePredictEdbInfoArr []*data_manage.EdbInfo, newCalculateMap, newPredictCalculateMap map[int]*data_manage.EdbInfo, calculateArr, predictCalculateArr []int) (err error, errmsg string) {
|
|
|
defer func() {
|
|
|
if err != nil {
|
|
|
fmt.Println("EdbInfoRefreshAllFromBaseV2 Err:" + err.Error() + ";errmsg:" + errmsg)
|
|
|
go alarm_msg.SendAlarmMsg("EdbInfoRefreshFromBaseV2,Err"+err.Error()+";errMsg:"+errmsg, 3)
|
|
|
-
|
|
|
}
|
|
|
}()
|
|
|
|
|
|
var startDate string
|
|
|
for _, bv := range newBaseEdbInfoArr {
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
if bv.StartDate == "0000-00-00" {
|
|
|
continue
|
|
|
}
|
|
|
-
|
|
|
startDate = utils.BaseEdbRefreshStartDate
|
|
|
if !refreshAll {
|
|
|
sDate := bv.EndDate
|
|
@@ -685,23 +612,9 @@ func edbInfoRefreshAll(refreshAll bool, newBaseEdbInfoArr, newBasePredictEdbInfo
|
|
|
return
|
|
|
}
|
|
|
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
fmt.Println("end newBaseEdbInfoArr:", bv, time.Now())
|
|
|
}
|
|
|
|
|
|
-
|
|
|
for _, v := range calculateArr {
|
|
|
edbInfo := newCalculateMap[v]
|
|
|
if edbInfo == nil {
|
|
@@ -759,7 +672,6 @@ func edbInfoRefreshAll(refreshAll bool, newBaseEdbInfoArr, newBasePredictEdbInfo
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-
|
|
|
for _, v := range predictCalculateArr {
|
|
|
edbInfo := newPredictCalculateMap[v]
|
|
|
if edbInfo == nil {
|
|
@@ -817,7 +729,6 @@ func edbInfoRefreshAll(refreshAll bool, newBaseEdbInfoArr, newBasePredictEdbInfo
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-
|
|
|
{
|
|
|
predictEdbInfoIdList := make([]int, 0)
|
|
|
for _, v := range newBasePredictEdbInfoArr {
|
|
@@ -848,7 +759,6 @@ func edbInfoRefreshAll(refreshAll bool, newBaseEdbInfoArr, newBasePredictEdbInfo
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-
|
|
|
for _, v := range predictCalculateArr {
|
|
|
edbInfo := newPredictCalculateMap[v]
|
|
|
if edbInfo == nil {
|
|
@@ -909,16 +819,6 @@ func edbInfoRefreshAll(refreshAll bool, newBaseEdbInfoArr, newBasePredictEdbInfo
|
|
|
return
|
|
|
}
|
|
|
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
func EdbInfoRefreshAllFromBase(edbInfoIdList []int, refreshAll bool) (err error, errMsg string) {
|
|
|
defer func() {
|
|
|
if err != nil {
|
|
@@ -930,26 +830,21 @@ func EdbInfoRefreshAllFromBase(edbInfoIdList []int, refreshAll bool) (err error,
|
|
|
if err != nil {
|
|
|
return
|
|
|
}
|
|
|
-
|
|
|
existEdbInfoIdMap := make(map[int]int)
|
|
|
|
|
|
-
|
|
|
newBaseEdbInfoArr := make([]*data_manage.EdbInfo, 0)
|
|
|
newBasePredictEdbInfoArr := make([]*data_manage.EdbInfo, 0)
|
|
|
newBaseMap := make(map[int]*data_manage.EdbInfo)
|
|
|
newPredictBaseMap := make(map[int]*data_manage.EdbInfo)
|
|
|
|
|
|
-
|
|
|
newCalculateMap := make(map[int]*data_manage.EdbInfo)
|
|
|
newPredictCalculateMap := make(map[int]*data_manage.EdbInfo)
|
|
|
calculateArr := make([]int, 0)
|
|
|
predictCalculateArr := make([]int, 0)
|
|
|
|
|
|
-
|
|
|
for _, traceEdbInfo := range traceEdbInfoList {
|
|
|
tmpBaseEdbInfoArr, tmpBasePredictEdbInfoArr, tmpCalculateMap, tmpPredictCalculateMap, _, _ := getRefreshEdbInfoListByTraceEdbInfo(traceEdbInfo, existEdbInfoIdMap)
|
|
|
|
|
|
-
|
|
|
for _, edbInfo := range tmpBaseEdbInfoArr {
|
|
|
if _, ok := newBaseMap[edbInfo.EdbInfoId]; !ok {
|
|
|
if edbInfo.NoUpdate == 1 {
|
|
@@ -960,7 +855,6 @@ func EdbInfoRefreshAllFromBase(edbInfoIdList []int, refreshAll bool) (err error,
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-
|
|
|
for _, edbInfo := range tmpBasePredictEdbInfoArr {
|
|
|
if _, ok := newPredictBaseMap[edbInfo.EdbInfoId]; !ok {
|
|
|
newPredictBaseMap[edbInfo.EdbInfoId] = edbInfo
|
|
@@ -968,7 +862,6 @@ func EdbInfoRefreshAllFromBase(edbInfoIdList []int, refreshAll bool) (err error,
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-
|
|
|
for _, edbInfo := range tmpCalculateMap {
|
|
|
if _, ok := newCalculateMap[edbInfo.EdbInfoId]; !ok {
|
|
|
if edbInfo.NoUpdate == 1 {
|
|
@@ -979,7 +872,6 @@ func EdbInfoRefreshAllFromBase(edbInfoIdList []int, refreshAll bool) (err error,
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-
|
|
|
for _, edbInfo := range tmpPredictCalculateMap {
|
|
|
if _, ok := newPredictCalculateMap[edbInfo.EdbInfoId]; !ok {
|
|
|
newPredictCalculateMap[edbInfo.EdbInfoId] = edbInfo
|
|
@@ -988,39 +880,18 @@ func EdbInfoRefreshAllFromBase(edbInfoIdList []int, refreshAll bool) (err error,
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-
|
|
|
sort.Ints(calculateArr)
|
|
|
-
|
|
|
sort.Ints(predictCalculateArr)
|
|
|
|
|
|
-
|
|
|
totalEdbInfo := len(newBaseEdbInfoArr) + len(calculateArr) + len(predictCalculateArr) + len(newBasePredictEdbInfoArr)
|
|
|
if totalEdbInfo == 0 {
|
|
|
return
|
|
|
}
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
err, errMsg = edbInfoRefreshAll(refreshAll, newBaseEdbInfoArr, newBasePredictEdbInfoArr, newCalculateMap, newPredictCalculateMap, calculateArr, predictCalculateArr)
|
|
|
|
|
|
return
|
|
|
}
|
|
|
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
func getRefreshEdbInfoListByTraceEdbInfo(traceEdbInfo data_manage.TraceEdbInfoResp, existEdbInfoIdMap map[int]int) (newBaseEdbInfoArr, newBasePredictEdbInfoArr []*data_manage.EdbInfo, newCalculateMap, newPredictCalculateMap map[int]*data_manage.EdbInfo, calculateArr, predictCalculateArr []int) {
|
|
|
newBaseEdbInfoArr = make([]*data_manage.EdbInfo, 0)
|
|
|
newBasePredictEdbInfoArr = make([]*data_manage.EdbInfo, 0)
|
|
@@ -1037,7 +908,6 @@ func getRefreshEdbInfoListByTraceEdbInfo(traceEdbInfo data_manage.TraceEdbInfoRe
|
|
|
existEdbInfoIdMap[traceEdbInfo.EdbInfoId] = traceEdbInfo.EdbInfoId
|
|
|
|
|
|
switch traceEdbInfo.EdbInfoType {
|
|
|
-
|
|
|
case 0:
|
|
|
if traceEdbInfo.EdbType == 1 {
|
|
|
newBaseEdbInfoArr = append(newBaseEdbInfoArr, traceEdbInfo.EdbInfo)
|
|
@@ -1077,14 +947,6 @@ func getRefreshEdbInfoListByTraceEdbInfo(traceEdbInfo data_manage.TraceEdbInfoRe
|
|
|
return
|
|
|
}
|
|
|
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
func TraceEdbInfoByEdbInfoIdList(edbInfoIdList []int) (traceEdbInfoList []data_manage.TraceEdbInfoResp, err error) {
|
|
|
traceEdbInfoList = make([]data_manage.TraceEdbInfoResp, 0)
|
|
|
edbInfoList, err := data_manage.GetEdbInfoByIdList(edbInfoIdList)
|
|
@@ -1099,14 +961,11 @@ func TraceEdbInfoByEdbInfoIdList(edbInfoIdList []int) (traceEdbInfoList []data_m
|
|
|
|
|
|
for _, edbInfo := range edbInfoList {
|
|
|
findIdMap[edbInfo.EdbInfoId] = edbInfo.EdbInfoId
|
|
|
-
|
|
|
traceEdbInfo := data_manage.TraceEdbInfoResp{
|
|
|
-
|
|
|
EdbInfoId: edbInfo.EdbInfoId,
|
|
|
EdbInfoType: edbInfo.EdbInfoType,
|
|
|
EdbName: edbInfo.EdbName,
|
|
|
EdbType: edbInfo.EdbType,
|
|
|
-
|
|
|
UniqueCode: edbInfo.UniqueCode,
|
|
|
ClassifyId: edbInfo.ClassifyId,
|
|
|
EdbInfo: edbInfo,
|
|
@@ -1115,37 +974,9 @@ func TraceEdbInfoByEdbInfoIdList(edbInfoIdList []int) (traceEdbInfoList []data_m
|
|
|
traceEdbInfoList = append(traceEdbInfoList, traceEdbInfo)
|
|
|
}
|
|
|
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
return
|
|
|
}
|
|
|
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
func traceEdbInfoByEdbInfoId(edbInfoId int, traceEdbInfo data_manage.TraceEdbInfoResp, edbInfoRuleMap map[int]string, findIdMap map[int]int, existMap map[int]data_manage.TraceEdbInfoResp, edbMappingMap map[int][]*data_manage.EdbInfoCalculateMappingInfo) (child []data_manage.TraceEdbInfoResp, err error) {
|
|
|
traceEdbInfo, ok := existMap[edbInfoId]
|
|
|
if ok {
|
|
@@ -1159,7 +990,6 @@ func traceEdbInfoByEdbInfoId(edbInfoId int, traceEdbInfo data_manage.TraceEdbInf
|
|
|
return
|
|
|
}
|
|
|
|
|
|
-
|
|
|
edbInfoMap := make(map[int]*data_manage.EdbInfo)
|
|
|
if len(edbInfoMappingList) > 0 {
|
|
|
fromEdbInfoIdList := make([]int, 0)
|
|
@@ -1189,9 +1019,7 @@ func traceEdbInfoByEdbInfoId(edbInfoId int, traceEdbInfo data_manage.TraceEdbInf
|
|
|
EdbInfo: edbInfoMap[v.FromEdbInfoId],
|
|
|
}
|
|
|
|
|
|
-
|
|
|
if edbInfoId != v.FromEdbInfoId && (v.FromEdbType == 2 || v.FromEdbInfoType == 1) {
|
|
|
-
|
|
|
if _, ok2 := findIdMap[tmpEdbInfoId]; !ok2 {
|
|
|
tmpTraceEdbInfo.Child, e = traceEdbInfoByEdbInfoId(tmpEdbInfoId, tmpTraceEdbInfo, edbInfoRuleMap, findIdMap, existMap, edbMappingMap)
|
|
|
if e != nil {
|
|
@@ -1207,7 +1035,6 @@ func traceEdbInfoByEdbInfoId(edbInfoId int, traceEdbInfo data_manage.TraceEdbInf
|
|
|
return
|
|
|
}
|
|
|
|
|
|
-
|
|
|
func GetEdbSourceByEdbInfoIdListForExcel(edbInfoIdList []int) (sourceNameList, sourceNameEnList []string, err error) {
|
|
|
sourceNameList = make([]string, 0)
|
|
|
sourceNameEnList = make([]string, 0)
|
|
@@ -1218,9 +1045,7 @@ func GetEdbSourceByEdbInfoIdListForExcel(edbInfoIdList []int) (sourceNameList, s
|
|
|
return
|
|
|
}
|
|
|
for _, v := range edbInfoList {
|
|
|
-
|
|
|
if v.EdbType == 2 {
|
|
|
-
|
|
|
baseEdbInfoArr, _, _ := data_manage.GetRefreshEdbInfoFromBase(v.EdbInfoId, v.Source)
|
|
|
for _, baseEdbInfo := range baseEdbInfoArr {
|
|
|
if baseEdbInfo.EdbInfoType == 0 {
|
|
@@ -1244,10 +1069,7 @@ func GetEdbSourceByEdbInfoIdListForExcel(edbInfoIdList []int) (sourceNameList, s
|
|
|
}
|
|
|
sourceNameEnList = append(sourceNameEnList, sourceNameEn)
|
|
|
}
|
|
|
-
|
|
|
-
|
|
|
|
|
|
-
|
|
|
conf, e := models.GetBusinessConf()
|
|
|
if e != nil {
|
|
|
return
|
|
@@ -1259,7 +1081,6 @@ func GetEdbSourceByEdbInfoIdListForExcel(edbInfoIdList []int) (sourceNameList, s
|
|
|
return
|
|
|
}
|
|
|
|
|
|
-
|
|
|
func HandleDataByLinearRegressionToList(edbInfoDataList []*models.EdbDataList, handleDataMap map[string]float64) (dataTimeList []string, valueList []float64, err error) {
|
|
|
if len(edbInfoDataList) < 2 {
|
|
|
return
|
|
@@ -1269,26 +1090,21 @@ func HandleDataByLinearRegressionToList(edbInfoDataList []*models.EdbDataList, h
|
|
|
for _, v := range edbInfoDataList {
|
|
|
handleDataMap[v.DataTime] = v.Value
|
|
|
dataTimeList = append(dataTimeList, v.DataTime)
|
|
|
-
|
|
|
if startEdbInfoData == nil {
|
|
|
startEdbInfoData = v
|
|
|
-
|
|
|
continue
|
|
|
}
|
|
|
|
|
|
-
|
|
|
startDataTime, _ := time.ParseInLocation(utils.FormatDate, startEdbInfoData.DataTime, time.Local)
|
|
|
currDataTime, _ := time.ParseInLocation(utils.FormatDate, v.DataTime, time.Local)
|
|
|
betweenHour := int(currDataTime.Sub(startDataTime).Hours())
|
|
|
betweenDay := betweenHour / 24
|
|
|
|
|
|
-
|
|
|
if betweenDay <= 1 {
|
|
|
startEdbInfoData = v
|
|
|
continue
|
|
|
}
|
|
|
|
|
|
-
|
|
|
var a, b float64
|
|
|
{
|
|
|
coordinateData := make([]utils.Coordinate, 0)
|
|
@@ -1310,7 +1126,6 @@ func HandleDataByLinearRegressionToList(edbInfoDataList []*models.EdbDataList, h
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-
|
|
|
{
|
|
|
for i := 1; i < betweenDay; i++ {
|
|
|
tmpDataTime := startDataTime.AddDate(0, 0, i)
|
|
@@ -1331,19 +1146,16 @@ func HandleDataByLinearRegressionToList(edbInfoDataList []*models.EdbDataList, h
|
|
|
return
|
|
|
}
|
|
|
|
|
|
-
|
|
|
func HandleDataByLinearRegressionToListV2(edbInfoDataList []*models.EdbDataList, handleDataMap map[string]float64) (dataTimeList []string, valueList []float64, err error) {
|
|
|
if len(edbInfoDataList) < 2 {
|
|
|
return
|
|
|
}
|
|
|
|
|
|
-
|
|
|
if len(edbInfoDataList) < 2 {
|
|
|
err = errors.New("至少需要两天的数据来执行线性插值")
|
|
|
return
|
|
|
}
|
|
|
|
|
|
-
|
|
|
sort.Slice(edbInfoDataList, func(i, j int) bool {
|
|
|
t1, _ := time.ParseInLocation(utils.FormatDate, edbInfoDataList[i].DataTime, time.Local)
|
|
|
t2, _ := time.ParseInLocation(utils.FormatDate, edbInfoDataList[j].DataTime, time.Local)
|
|
@@ -1353,21 +1165,17 @@ func HandleDataByLinearRegressionToListV2(edbInfoDataList []*models.EdbDataList,
|
|
|
startEdbInfoData := edbInfoDataList[0]
|
|
|
endEdbInfoData := edbInfoDataList[len(edbInfoDataList)-1]
|
|
|
|
|
|
-
|
|
|
startDate, _ := time.ParseInLocation(utils.FormatDate, startEdbInfoData.DataTime, time.Local)
|
|
|
endDate, _ := time.ParseInLocation(utils.FormatDate, endEdbInfoData.DataTime, time.Local)
|
|
|
actualDays := endDate.Sub(startDate).Hours() / 24
|
|
|
|
|
|
-
|
|
|
for _, v := range edbInfoDataList {
|
|
|
handleDataMap[v.DataTime] = v.Value
|
|
|
dataTimeList = append(dataTimeList, v.DataTime)
|
|
|
valueList = append(valueList, v.Value)
|
|
|
}
|
|
|
|
|
|
-
|
|
|
if actualDays < 365 {
|
|
|
-
|
|
|
var a, b float64
|
|
|
coordinateData := []utils.Coordinate{
|
|
|
{X: 1, Y: startEdbInfoData.Value},
|
|
@@ -1379,7 +1187,6 @@ func HandleDataByLinearRegressionToListV2(edbInfoDataList []*models.EdbDataList,
|
|
|
return
|
|
|
}
|
|
|
|
|
|
-
|
|
|
for i := 1; i < 365; i++ {
|
|
|
day := startDate.AddDate(0, 0, i)
|
|
|
if _, exists := handleDataMap[day.Format(utils.FormatDate)]; !exists {
|
|
@@ -1398,7 +1205,6 @@ func HandleDataByLinearRegressionToListV2(edbInfoDataList []*models.EdbDataList,
|
|
|
return
|
|
|
}
|
|
|
|
|
|
-
|
|
|
func HandleDataByLinearRegressionToListV3(edbInfoDataList []*models.EdbDataList, handleDataMap map[string]float64) (newEdbInfoDataList []*models.EdbDataList, dataTimeList []string, valueList []float64, err error) {
|
|
|
if len(edbInfoDataList) < 2 {
|
|
|
return
|
|
@@ -1409,26 +1215,21 @@ func HandleDataByLinearRegressionToListV3(edbInfoDataList []*models.EdbDataList,
|
|
|
handleDataMap[v.DataTime] = v.Value
|
|
|
newEdbInfoDataList = append(newEdbInfoDataList, v)
|
|
|
dataTimeList = append(dataTimeList, v.DataTime)
|
|
|
-
|
|
|
if startEdbInfoData == nil {
|
|
|
startEdbInfoData = v
|
|
|
-
|
|
|
continue
|
|
|
}
|
|
|
|
|
|
-
|
|
|
startDataTime, _ := time.ParseInLocation(utils.FormatDate, startEdbInfoData.DataTime, time.Local)
|
|
|
currDataTime, _ := time.ParseInLocation(utils.FormatDate, v.DataTime, time.Local)
|
|
|
betweenHour := int(currDataTime.Sub(startDataTime).Hours())
|
|
|
betweenDay := betweenHour / 24
|
|
|
|
|
|
-
|
|
|
if betweenDay <= 1 {
|
|
|
startEdbInfoData = v
|
|
|
continue
|
|
|
}
|
|
|
|
|
|
-
|
|
|
var a, b float64
|
|
|
{
|
|
|
coordinateData := make([]utils.Coordinate, 0)
|
|
@@ -1450,7 +1251,6 @@ func HandleDataByLinearRegressionToListV3(edbInfoDataList []*models.EdbDataList,
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-
|
|
|
{
|
|
|
for i := 1; i < betweenDay; i++ {
|
|
|
tmpDataTime := startDataTime.AddDate(0, 0, i)
|