|
@@ -239,42 +239,12 @@ func SyncXDateYQuotaData(classifyId int, dbCode, classifyCode string) (err error
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- // 指标编码去重, 指标编码+日期数据去重
|
|
|
- indexOB := new(models.BaseFromNationalStatisticsIndex)
|
|
|
- indexCond := ` AND dbcode = ?`
|
|
|
- indexPars := make([]interface{}, 0)
|
|
|
- indexPars = append(indexPars, dbCode)
|
|
|
- indexList, e := indexOB.GetItemsByCondition(indexCond, indexPars, []string{"index_code"}, "")
|
|
|
- if e != nil {
|
|
|
- err = fmt.Errorf("获取指标列表失败, Err: %s", e.Error())
|
|
|
- return
|
|
|
- }
|
|
|
- indexExistMap := make(map[string]bool)
|
|
|
- for _, v := range indexList {
|
|
|
- indexExistMap[v.IndexCode] = true
|
|
|
- }
|
|
|
-
|
|
|
// 遍历XY轴
|
|
|
indexDataList := make([]*models.SaveNationalStatisticsIndexAndDataReq, 0)
|
|
|
indexDataMap := make(map[string][]*models.BaseFromNationalStatisticsData)
|
|
|
for _, q := range quotaNodes {
|
|
|
indexCode := fmt.Sprintf("%s%s", dbCode, q.Code)
|
|
|
|
|
|
- // 数据去重
|
|
|
- dataExistMap := make(map[string]bool)
|
|
|
- dataOB := new(models.BaseFromNationalStatisticsData)
|
|
|
- dataCond := ` AND index_code = ?`
|
|
|
- dataPars := make([]interface{}, 0)
|
|
|
- dataPars = append(dataPars, indexCode)
|
|
|
- dataList, e := dataOB.GetItemsByCondition(dataCond, dataPars, []string{"index_code", "data_time"}, "")
|
|
|
- if e != nil {
|
|
|
- err = fmt.Errorf("获取指标数据列表失败, Err: %s", e.Error())
|
|
|
- return
|
|
|
- }
|
|
|
- for _, v := range dataList {
|
|
|
- dataExistMap[v.DataTime.Format(utils.FormatDate)] = true
|
|
|
- }
|
|
|
-
|
|
|
// 指标
|
|
|
r := new(models.SaveNationalStatisticsIndexAndDataReq)
|
|
|
r.Index = &models.BaseFromNationalStatisticsIndex{
|
|
@@ -287,9 +257,6 @@ func SyncXDateYQuotaData(classifyId int, dbCode, classifyCode string) (err error
|
|
|
CreateTime: time.Now().Local(),
|
|
|
ModifyTime: time.Now().Local(),
|
|
|
}
|
|
|
- if indexExistMap[indexCode] {
|
|
|
- r.IndexExist = true
|
|
|
- }
|
|
|
|
|
|
// 数据
|
|
|
for _, d := range dateNodes {
|
|
@@ -299,14 +266,12 @@ func SyncXDateYQuotaData(classifyId int, dbCode, classifyCode string) (err error
|
|
|
continue
|
|
|
}
|
|
|
|
|
|
+ // 日期处理
|
|
|
t, e := formatMonth2YearDateCode(d.Code)
|
|
|
if e != nil {
|
|
|
err = fmt.Errorf("格式化日期code失败, Err: %s", e.Error())
|
|
|
return
|
|
|
}
|
|
|
- if dataExistMap[t.Format(utils.FormatDate)] {
|
|
|
- continue
|
|
|
- }
|
|
|
|
|
|
// 数据map
|
|
|
if indexDataMap[indexCode] == nil {
|
|
@@ -330,7 +295,7 @@ func SyncXDateYQuotaData(classifyId int, dbCode, classifyCode string) (err error
|
|
|
continue
|
|
|
}
|
|
|
v.DataList = ds
|
|
|
- if e := models.SaveNationalStatisticsIndexAndData(v); e != nil {
|
|
|
+ if e := models.SaveNationalStatisticsIndexAndData(v.Index, v.DataList); e != nil {
|
|
|
err = fmt.Errorf("保存指标和数据失败, Err: %s", e.Error())
|
|
|
return
|
|
|
}
|
|
@@ -478,21 +443,6 @@ func SyncXDateYQuotaZRegData(classifyId int, dbCode, classifyCode string, regLis
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- // 指标编码去重, 指标编码+日期数据去重
|
|
|
- indexOB := new(models.BaseFromNationalStatisticsIndex)
|
|
|
- indexCond := ` AND dbcode = ?`
|
|
|
- indexPars := make([]interface{}, 0)
|
|
|
- indexPars = append(indexPars, dbCode)
|
|
|
- indexList, e := indexOB.GetItemsByCondition(indexCond, indexPars, []string{"index_code"}, "")
|
|
|
- if e != nil {
|
|
|
- err = fmt.Errorf("获取指标列表失败, Err: %s", e.Error())
|
|
|
- return
|
|
|
- }
|
|
|
- indexExistMap := make(map[string]bool)
|
|
|
- for _, v := range indexList {
|
|
|
- indexExistMap[v.IndexCode] = true
|
|
|
- }
|
|
|
-
|
|
|
// 遍历XY轴
|
|
|
indexDataList := make([]*models.SaveNationalStatisticsIndexAndDataReq, 0)
|
|
|
indexDataMap := make(map[string][]*models.BaseFromNationalStatisticsData)
|
|
@@ -500,21 +450,6 @@ func SyncXDateYQuotaZRegData(classifyId int, dbCode, classifyCode string, regLis
|
|
|
// dbcode+指标code+地区code
|
|
|
indexCode := fmt.Sprintf("%s%s%s", dbCode, q.Code, reg.Code)
|
|
|
|
|
|
- // 数据去重
|
|
|
- dataExistMap := make(map[string]bool)
|
|
|
- dataOB := new(models.BaseFromNationalStatisticsData)
|
|
|
- dataCond := ` AND index_code = ?`
|
|
|
- dataPars := make([]interface{}, 0)
|
|
|
- dataPars = append(dataPars, indexCode)
|
|
|
- dataList, e := dataOB.GetItemsByCondition(dataCond, dataPars, []string{"index_code", "data_time"}, "")
|
|
|
- if e != nil {
|
|
|
- err = fmt.Errorf("获取指标数据列表失败, Err: %s", e.Error())
|
|
|
- return
|
|
|
- }
|
|
|
- for _, v := range dataList {
|
|
|
- dataExistMap[v.DataTime.Format(utils.FormatDate)] = true
|
|
|
- }
|
|
|
-
|
|
|
// 指标
|
|
|
r := new(models.SaveNationalStatisticsIndexAndDataReq)
|
|
|
r.Index = &models.BaseFromNationalStatisticsIndex{
|
|
@@ -528,9 +463,6 @@ func SyncXDateYQuotaZRegData(classifyId int, dbCode, classifyCode string, regLis
|
|
|
CreateTime: time.Now().Local(),
|
|
|
ModifyTime: time.Now().Local(),
|
|
|
}
|
|
|
- if indexExistMap[indexCode] {
|
|
|
- r.IndexExist = true
|
|
|
- }
|
|
|
|
|
|
// 数据
|
|
|
// zb.A01010201_reg.110000_sj.201608
|
|
@@ -541,14 +473,12 @@ func SyncXDateYQuotaZRegData(classifyId int, dbCode, classifyCode string, regLis
|
|
|
continue
|
|
|
}
|
|
|
|
|
|
+ // 日期处理
|
|
|
t, e := formatMonth2YearDateCode(d.Code)
|
|
|
if e != nil {
|
|
|
err = fmt.Errorf("格式化日期code失败, Err: %s", e.Error())
|
|
|
return
|
|
|
}
|
|
|
- if dataExistMap[t.Format(utils.FormatDate)] {
|
|
|
- continue
|
|
|
- }
|
|
|
|
|
|
// 数据map
|
|
|
if indexDataMap[indexCode] == nil {
|
|
@@ -572,7 +502,7 @@ func SyncXDateYQuotaZRegData(classifyId int, dbCode, classifyCode string, regLis
|
|
|
continue
|
|
|
}
|
|
|
v.DataList = ds
|
|
|
- if e := models.SaveNationalStatisticsIndexAndData(v); e != nil {
|
|
|
+ if e := models.SaveNationalStatisticsIndexAndData(v.Index, v.DataList); e != nil {
|
|
|
err = fmt.Errorf("保存指标和数据失败, Err: %s", e.Error())
|
|
|
return
|
|
|
}
|
|
@@ -751,21 +681,6 @@ func SyncXRegYDateZQuotaDbData(classifyId int, dbCode, classifyCode string) (err
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- // 指标编码去重, 指标编码+日期数据去重
|
|
|
- indexOB := new(models.BaseFromNationalStatisticsIndex)
|
|
|
- indexCond := ` AND dbcode = ?`
|
|
|
- indexPars := make([]interface{}, 0)
|
|
|
- indexPars = append(indexPars, dbCode)
|
|
|
- indexList, e := indexOB.GetItemsByCondition(indexCond, indexPars, []string{"index_code"}, "")
|
|
|
- if e != nil {
|
|
|
- err = fmt.Errorf("获取指标列表失败, Err: %s", e.Error())
|
|
|
- return
|
|
|
- }
|
|
|
- indexExistMap := make(map[string]bool)
|
|
|
- for _, v := range indexList {
|
|
|
- indexExistMap[v.IndexCode] = true
|
|
|
- }
|
|
|
-
|
|
|
// 遍历XY轴
|
|
|
indexDataList := make([]*models.SaveNationalStatisticsIndexAndDataReq, 0)
|
|
|
indexDataMap := make(map[string][]*models.BaseFromNationalStatisticsData)
|
|
@@ -775,21 +690,6 @@ func SyncXRegYDateZQuotaDbData(classifyId int, dbCode, classifyCode string) (err
|
|
|
// 指标: dbcode+指标code+地区code
|
|
|
indexCode := fmt.Sprintf("%s%s%s", dbCode, quota.Code, reg.Code)
|
|
|
|
|
|
- // 数据去重
|
|
|
- dataExistMap := make(map[string]bool)
|
|
|
- dataOB := new(models.BaseFromNationalStatisticsData)
|
|
|
- dataCond := ` AND index_code = ?`
|
|
|
- dataPars := make([]interface{}, 0)
|
|
|
- dataPars = append(dataPars, indexCode)
|
|
|
- dataList, e := dataOB.GetItemsByCondition(dataCond, dataPars, []string{"index_code", "data_time"}, "")
|
|
|
- if e != nil {
|
|
|
- err = fmt.Errorf("获取指标数据列表失败, Err: %s", e.Error())
|
|
|
- return
|
|
|
- }
|
|
|
- for _, v := range dataList {
|
|
|
- dataExistMap[v.DataTime.Format(utils.FormatDate)] = true
|
|
|
- }
|
|
|
-
|
|
|
r := new(models.SaveNationalStatisticsIndexAndDataReq)
|
|
|
r.Index = &models.BaseFromNationalStatisticsIndex{
|
|
|
BaseFromNationalStatisticsClassifyId: classifyId,
|
|
@@ -802,9 +702,6 @@ func SyncXRegYDateZQuotaDbData(classifyId int, dbCode, classifyCode string) (err
|
|
|
CreateTime: time.Now().Local(),
|
|
|
ModifyTime: time.Now().Local(),
|
|
|
}
|
|
|
- if indexExistMap[indexCode] {
|
|
|
- r.IndexExist = true
|
|
|
- }
|
|
|
|
|
|
// 遍历Y轴-日期
|
|
|
for _, d := range dateNodes {
|
|
@@ -820,9 +717,6 @@ func SyncXRegYDateZQuotaDbData(classifyId int, dbCode, classifyCode string) (err
|
|
|
err = fmt.Errorf("格式化日期code失败, Err: %s", e.Error())
|
|
|
return
|
|
|
}
|
|
|
- if dataExistMap[t.Format(utils.FormatDate)] {
|
|
|
- continue
|
|
|
- }
|
|
|
|
|
|
// 数据map
|
|
|
if indexDataMap[indexCode] == nil {
|
|
@@ -846,7 +740,7 @@ func SyncXRegYDateZQuotaDbData(classifyId int, dbCode, classifyCode string) (err
|
|
|
continue
|
|
|
}
|
|
|
v.DataList = ds
|
|
|
- if e := models.SaveNationalStatisticsIndexAndData(v); e != nil {
|
|
|
+ if e := models.SaveNationalStatisticsIndexAndData(v.Index, v.DataList); e != nil {
|
|
|
err = fmt.Errorf("保存指标和数据失败, Err: %s", e.Error())
|
|
|
return
|
|
|
}
|