|
@@ -480,18 +480,13 @@ func (this *CalculateController) BatchSave() {
|
|
return
|
|
return
|
|
}
|
|
}
|
|
|
|
|
|
- if req.FromEdbInfoId <= 0 {
|
|
|
|
- br.Msg = "请选择指标"
|
|
|
|
- return
|
|
|
|
- }
|
|
|
|
|
|
+ // 基础指标id
|
|
|
|
+ fromEdbInfoId := req.FromEdbInfoId
|
|
|
|
|
|
var formulaInt int
|
|
var formulaInt int
|
|
-
|
|
|
|
- if req.Source == utils.DATA_SOURCE_CALCULATE_NSZYDPJJS ||
|
|
|
|
- req.Source == utils.DATA_SOURCE_CALCULATE_HBZ ||
|
|
|
|
- req.Source == utils.DATA_SOURCE_CALCULATE_HCZ ||
|
|
|
|
- req.Source == utils.DATA_SOURCE_CALCULATE_TIME_SHIFT ||
|
|
|
|
- req.Source == utils.DATA_SOURCE_CALCULATE_CJJX {
|
|
|
|
|
|
+ var nhccDate models.NhccDate // 拟合残差的日期
|
|
|
|
+ switch req.Source {
|
|
|
|
+ case utils.DATA_SOURCE_CALCULATE_NSZYDPJJS, utils.DATA_SOURCE_CALCULATE_HBZ, utils.DATA_SOURCE_CALCULATE_HCZ, utils.DATA_SOURCE_CALCULATE_TIME_SHIFT, utils.DATA_SOURCE_CALCULATE_CJJX:
|
|
if req.Formula == "" {
|
|
if req.Formula == "" {
|
|
br.Msg = "请填写N值"
|
|
br.Msg = "请填写N值"
|
|
return
|
|
return
|
|
@@ -501,17 +496,51 @@ func (this *CalculateController) BatchSave() {
|
|
br.Msg = "N值输入错误,请重新输入"
|
|
br.Msg = "N值输入错误,请重新输入"
|
|
return
|
|
return
|
|
}
|
|
}
|
|
- } else if req.Source == utils.DATA_SOURCE_CALCULATE_ZJPJ {
|
|
|
|
|
|
+ case utils.DATA_SOURCE_CALCULATE_ZJPJ:
|
|
//直接拼接指标
|
|
//直接拼接指标
|
|
-
|
|
|
|
//校验时间格式
|
|
//校验时间格式
|
|
_, err = time.ParseInLocation(utils.FormatDate, req.Formula, time.Local)
|
|
_, err = time.ParseInLocation(utils.FormatDate, req.Formula, time.Local)
|
|
if err != nil {
|
|
if err != nil {
|
|
br.Msg = "拼接日期有误,请重新输入"
|
|
br.Msg = "拼接日期有误,请重新输入"
|
|
return
|
|
return
|
|
}
|
|
}
|
|
|
|
+ case utils.DATA_SOURCE_CALCULATE_NHCC: //拟合残差指标
|
|
|
|
+ //指标校验
|
|
|
|
+ if len(req.EdbInfoIdArr) != 2 {
|
|
|
|
+ br.Msg = "选择的指标异常,请重新选择"
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+ fromEdbInfoId = req.EdbInfoIdArr[0].EdbInfoId
|
|
|
|
+
|
|
|
|
+ //校验时间格式
|
|
|
|
+ //数据格式:2022-11-01,2022-11-10
|
|
|
|
+ timeList := strings.Split(req.Formula, ",")
|
|
|
|
+ if len(timeList) != 2 {
|
|
|
|
+ br.Msg = "选择时间有误,请重新输入"
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+ startDate, err := time.ParseInLocation(utils.FormatDate, timeList[0], time.Local)
|
|
|
|
+ if err != nil {
|
|
|
|
+ br.Msg = "开始日期有误,请重新输入"
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+ endDate, err := time.ParseInLocation(utils.FormatDate, timeList[1], time.Local)
|
|
|
|
+ if err != nil {
|
|
|
|
+ br.Msg = "结束日期有误,请重新输入"
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+ if utils.GetTimeSubDay(startDate, endDate) < 2 {
|
|
|
|
+ br.Msg = "日期间隔不得少于两天"
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+ nhccDate.StartDate = startDate
|
|
|
|
+ nhccDate.EndDate = endDate
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ if fromEdbInfoId <= 0 {
|
|
|
|
+ br.Msg = "请选择指标"
|
|
|
|
+ return
|
|
|
|
+ }
|
|
//加入缓存机制,避免创建同一个名称的指标 start
|
|
//加入缓存机制,避免创建同一个名称的指标 start
|
|
redisKey := fmt.Sprint("edb_lib:edb_info:calculate:batch:save:", req.Source, ":", req.EdbName)
|
|
redisKey := fmt.Sprint("edb_lib:edb_info:calculate:batch:save:", req.Source, ":", req.EdbName)
|
|
isExist := utils.Rc.IsExist(redisKey)
|
|
isExist := utils.Rc.IsExist(redisKey)
|
|
@@ -546,7 +575,7 @@ func (this *CalculateController) BatchSave() {
|
|
return
|
|
return
|
|
}
|
|
}
|
|
|
|
|
|
- fromEdbInfo, err := models.GetEdbInfoById(req.FromEdbInfoId)
|
|
|
|
|
|
+ fromEdbInfo, err := models.GetEdbInfoById(fromEdbInfoId)
|
|
if err != nil {
|
|
if err != nil {
|
|
br.Msg = "获取指标信息失败"
|
|
br.Msg = "获取指标信息失败"
|
|
br.ErrMsg = "获取指标信息失败:Err:" + err.Error()
|
|
br.ErrMsg = "获取指标信息失败:Err:" + err.Error()
|
|
@@ -565,27 +594,28 @@ func (this *CalculateController) BatchSave() {
|
|
var sourName string
|
|
var sourName string
|
|
var edbInfoId int
|
|
var edbInfoId int
|
|
var edbInfo *models.EdbInfo
|
|
var edbInfo *models.EdbInfo
|
|
- if req.Source == utils.DATA_SOURCE_CALCULATE_LJZZY {
|
|
|
|
|
|
+ switch req.Source {
|
|
|
|
+ case utils.DATA_SOURCE_CALCULATE_LJZZY:
|
|
sourName = "累计值转月值"
|
|
sourName = "累计值转月值"
|
|
if fromEdbInfo.Frequency != "月度" {
|
|
if fromEdbInfo.Frequency != "月度" {
|
|
br.Msg = "请选择月度指标"
|
|
br.Msg = "请选择月度指标"
|
|
return
|
|
return
|
|
}
|
|
}
|
|
edbInfo, err = models.AddCalculateLjzzy(&req, fromEdbInfo, edbCode, uniqueCode, sysUserId, sysUserName)
|
|
edbInfo, err = models.AddCalculateLjzzy(&req, fromEdbInfo, edbCode, uniqueCode, sysUserId, sysUserName)
|
|
- } else if req.Source == utils.DATA_SOURCE_CALCULATE_TBZ {
|
|
|
|
|
|
+ case utils.DATA_SOURCE_CALCULATE_TBZ:
|
|
sourName = "同比值"
|
|
sourName = "同比值"
|
|
edbInfo, err = models.AddCalculateTbz(&req, fromEdbInfo, edbCode, uniqueCode, sysUserId, sysUserName)
|
|
edbInfo, err = models.AddCalculateTbz(&req, fromEdbInfo, edbCode, uniqueCode, sysUserId, sysUserName)
|
|
- } else if req.Source == utils.DATA_SOURCE_CALCULATE_TCZ {
|
|
|
|
|
|
+ case utils.DATA_SOURCE_CALCULATE_TCZ:
|
|
sourName = "同差值"
|
|
sourName = "同差值"
|
|
edbInfo, err = models.AddCalculateTcz(&req, fromEdbInfo, edbCode, uniqueCode, sysUserId, sysUserName)
|
|
edbInfo, err = models.AddCalculateTcz(&req, fromEdbInfo, edbCode, uniqueCode, sysUserId, sysUserName)
|
|
- } else if req.Source == utils.DATA_SOURCE_CALCULATE_NSZYDPJJS {
|
|
|
|
|
|
+ case utils.DATA_SOURCE_CALCULATE_NSZYDPJJS:
|
|
sourName = "N数值移动平均计算"
|
|
sourName = "N数值移动平均计算"
|
|
edbInfo, err = models.AddCalculateNszydpjjs(&req, fromEdbInfo, edbCode, uniqueCode, sysUserId, sysUserName, formulaInt)
|
|
edbInfo, err = models.AddCalculateNszydpjjs(&req, fromEdbInfo, edbCode, uniqueCode, sysUserId, sysUserName, formulaInt)
|
|
- } else if req.Source == utils.DATA_SOURCE_CALCULATE_HBZ {
|
|
|
|
|
|
+ case utils.DATA_SOURCE_CALCULATE_HBZ:
|
|
var condition string
|
|
var condition string
|
|
var pars []interface{}
|
|
var pars []interface{}
|
|
condition += " AND edb_info_id =? "
|
|
condition += " AND edb_info_id =? "
|
|
- pars = append(pars, req.FromEdbInfoId)
|
|
|
|
|
|
+ pars = append(pars, fromEdbInfoId)
|
|
condition += " AND value <=0 "
|
|
condition += " AND value <=0 "
|
|
checkCount, err := models.GetEdbDataCount(condition, pars, fromEdbInfo.Source)
|
|
checkCount, err := models.GetEdbDataCount(condition, pars, fromEdbInfo.Source)
|
|
if err != nil && err.Error() != utils.ErrNoRow() {
|
|
if err != nil && err.Error() != utils.ErrNoRow() {
|
|
@@ -600,10 +630,10 @@ func (this *CalculateController) BatchSave() {
|
|
}
|
|
}
|
|
sourName = "环比值"
|
|
sourName = "环比值"
|
|
edbInfo, err = models.AddCalculateHbz(&req, fromEdbInfo, edbCode, uniqueCode, sysUserId, sysUserName, formulaInt)
|
|
edbInfo, err = models.AddCalculateHbz(&req, fromEdbInfo, edbCode, uniqueCode, sysUserId, sysUserName, formulaInt)
|
|
- } else if req.Source == utils.DATA_SOURCE_CALCULATE_HCZ {
|
|
|
|
|
|
+ case utils.DATA_SOURCE_CALCULATE_HCZ:
|
|
sourName = "环差值"
|
|
sourName = "环差值"
|
|
edbInfo, err = models.AddCalculateHcz(&req, fromEdbInfo, edbCode, uniqueCode, sysUserId, sysUserName, formulaInt)
|
|
edbInfo, err = models.AddCalculateHcz(&req, fromEdbInfo, edbCode, uniqueCode, sysUserId, sysUserName, formulaInt)
|
|
- } else if req.Source == utils.DATA_SOURCE_CALCULATE_BP {
|
|
|
|
|
|
+ case utils.DATA_SOURCE_CALCULATE_BP:
|
|
//if fromEdbInfo.Frequency == "日度" {
|
|
//if fromEdbInfo.Frequency == "日度" {
|
|
// br.Msg = "日度指标,无法进行变频操作"
|
|
// br.Msg = "日度指标,无法进行变频操作"
|
|
// br.ErrMsg = "日度指标,无法进行变频操作:edbcode:" + fromEdbInfo.EdbCode
|
|
// br.ErrMsg = "日度指标,无法进行变频操作:edbcode:" + fromEdbInfo.EdbCode
|
|
@@ -611,10 +641,10 @@ func (this *CalculateController) BatchSave() {
|
|
//}
|
|
//}
|
|
sourName = "变频"
|
|
sourName = "变频"
|
|
edbInfo, err = models.AddCalculateBp(&req, fromEdbInfo, edbCode, uniqueCode, sysUserId, sysUserName)
|
|
edbInfo, err = models.AddCalculateBp(&req, fromEdbInfo, edbCode, uniqueCode, sysUserId, sysUserName)
|
|
- } else if req.Source == utils.DATA_SOURCE_CALCULATE_TIME_SHIFT { //时间移位
|
|
|
|
|
|
+ case utils.DATA_SOURCE_CALCULATE_TIME_SHIFT:
|
|
sourName = "时间移位"
|
|
sourName = "时间移位"
|
|
edbInfo, err = models.AddCalculateTimeShift(&req, fromEdbInfo, edbCode, uniqueCode, sysUserId, sysUserName)
|
|
edbInfo, err = models.AddCalculateTimeShift(&req, fromEdbInfo, edbCode, uniqueCode, sysUserId, sysUserName)
|
|
- } else if req.Source == utils.DATA_SOURCE_CALCULATE_ZJPJ { //直接拼接
|
|
|
|
|
|
+ case utils.DATA_SOURCE_CALCULATE_ZJPJ:
|
|
sourName = "直接拼接"
|
|
sourName = "直接拼接"
|
|
|
|
|
|
if len(req.EdbInfoIdArr) != 1 {
|
|
if len(req.EdbInfoIdArr) != 1 {
|
|
@@ -637,7 +667,7 @@ func (this *CalculateController) BatchSave() {
|
|
return
|
|
return
|
|
}
|
|
}
|
|
edbInfo, err = models.AddCalculateZjpj(&req, fromEdbInfo, secondEdbInfo, edbCode, uniqueCode, sysUserId, sysUserName)
|
|
edbInfo, err = models.AddCalculateZjpj(&req, fromEdbInfo, secondEdbInfo, edbCode, uniqueCode, sysUserId, sysUserName)
|
|
- } else if req.Source == utils.DATA_SOURCE_CALCULATE_LJZTBPJ { //累计值同比拼接
|
|
|
|
|
|
+ case utils.DATA_SOURCE_CALCULATE_LJZTBPJ:
|
|
sourName = "累计值同比拼接"
|
|
sourName = "累计值同比拼接"
|
|
|
|
|
|
if fromEdbInfo.Frequency != "月度" {
|
|
if fromEdbInfo.Frequency != "月度" {
|
|
@@ -675,10 +705,27 @@ func (this *CalculateController) BatchSave() {
|
|
return
|
|
return
|
|
}
|
|
}
|
|
edbInfo, err = models.AddCalculateLjztbpj(&req, fromEdbInfo, tbzEdbInfo, edbCode, uniqueCode, sysUserId, sysUserName)
|
|
edbInfo, err = models.AddCalculateLjztbpj(&req, fromEdbInfo, tbzEdbInfo, edbCode, uniqueCode, sysUserId, sysUserName)
|
|
- } else if req.Source == utils.DATA_SOURCE_CALCULATE_CJJX {
|
|
|
|
|
|
+ case utils.DATA_SOURCE_CALCULATE_CJJX:
|
|
sourName = "超季节性"
|
|
sourName = "超季节性"
|
|
edbInfo, err = models.AddCalculateCjjx(&req, fromEdbInfo, edbCode, uniqueCode, sysUserId, sysUserName, formulaInt)
|
|
edbInfo, err = models.AddCalculateCjjx(&req, fromEdbInfo, edbCode, uniqueCode, sysUserId, sysUserName, formulaInt)
|
|
- } else {
|
|
|
|
|
|
+ case utils.DATA_SOURCE_CALCULATE_NHCC:
|
|
|
|
+ sourName = "拟合残差"
|
|
|
|
+
|
|
|
|
+ secondEdbInfoReq := req.EdbInfoIdArr[1]
|
|
|
|
+ secondEdbInfo, err := models.GetEdbInfoById(secondEdbInfoReq.EdbInfoId)
|
|
|
|
+ if err != nil {
|
|
|
|
+ br.Msg = "获取因变量的指标信息失败"
|
|
|
|
+ br.ErrMsg = "获取因变量的指标信息失败:Err:" + err.Error()
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if fromEdbInfo.EdbInfoId == secondEdbInfo.EdbInfoId {
|
|
|
|
+ br.Msg = "两个指标不允许为同一个"
|
|
|
|
+ br.ErrMsg = "两个指标不允许为同一个"
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+ edbInfo, err = models.AddCalculateNhcc(&req, fromEdbInfo, secondEdbInfo, edbCode, uniqueCode, nhccDate, sysUserId, sysUserName)
|
|
|
|
+ default:
|
|
br.Msg = "无效计算方式"
|
|
br.Msg = "无效计算方式"
|
|
br.ErrMsg = "无效计算方式,source:" + strconv.Itoa(req.Source)
|
|
br.ErrMsg = "无效计算方式,source:" + strconv.Itoa(req.Source)
|
|
return
|
|
return
|
|
@@ -816,28 +863,18 @@ func (this *CalculateController) BatchEdit() {
|
|
return
|
|
return
|
|
}
|
|
}
|
|
|
|
|
|
- fromEdbInfo, err := models.GetEdbInfoById(req.FromEdbInfoId)
|
|
|
|
- if err != nil {
|
|
|
|
- if err.Error() == utils.ErrNoRow() {
|
|
|
|
- br.Msg = "指标已被删除,请刷新页面"
|
|
|
|
- br.ErrMsg = "指标已被删除,请刷新页面:Err:" + err.Error()
|
|
|
|
- return
|
|
|
|
- }
|
|
|
|
- br.Msg = "获取指标信息失败"
|
|
|
|
- br.ErrMsg = "获取指标信息失败:Err:" + err.Error()
|
|
|
|
- return
|
|
|
|
- }
|
|
|
|
|
|
+ // 基础指标id
|
|
|
|
+ fromEdbInfoId := req.FromEdbInfoId
|
|
|
|
|
|
if req.Source <= 0 {
|
|
if req.Source <= 0 {
|
|
req.Source = edbInfo.Source
|
|
req.Source = edbInfo.Source
|
|
}
|
|
}
|
|
|
|
|
|
var formulaInt int
|
|
var formulaInt int
|
|
- if req.Source == utils.DATA_SOURCE_CALCULATE_NSZYDPJJS ||
|
|
|
|
- req.Source == utils.DATA_SOURCE_CALCULATE_HBZ ||
|
|
|
|
- req.Source == utils.DATA_SOURCE_CALCULATE_HCZ ||
|
|
|
|
- req.Source == utils.DATA_SOURCE_CALCULATE_TIME_SHIFT ||
|
|
|
|
- req.Source == utils.DATA_SOURCE_CALCULATE_CJJX {
|
|
|
|
|
|
+ var nhccDate models.NhccDate // 拟合残差的日期
|
|
|
|
+ // 初期的参数校验
|
|
|
|
+ switch req.Source {
|
|
|
|
+ case utils.DATA_SOURCE_CALCULATE_NSZYDPJJS, utils.DATA_SOURCE_CALCULATE_HBZ, utils.DATA_SOURCE_CALCULATE_HCZ, utils.DATA_SOURCE_CALCULATE_TIME_SHIFT, utils.DATA_SOURCE_CALCULATE_CJJX:
|
|
if req.Formula == "" {
|
|
if req.Formula == "" {
|
|
br.Msg = "请填写N值"
|
|
br.Msg = "请填写N值"
|
|
return
|
|
return
|
|
@@ -847,7 +884,7 @@ func (this *CalculateController) BatchEdit() {
|
|
br.Msg = "N值输入错误,请重新输入"
|
|
br.Msg = "N值输入错误,请重新输入"
|
|
return
|
|
return
|
|
}
|
|
}
|
|
- } else if req.Source == utils.DATA_SOURCE_CALCULATE_ZJPJ {
|
|
|
|
|
|
+ case utils.DATA_SOURCE_CALCULATE_ZJPJ:
|
|
//直接拼接指标
|
|
//直接拼接指标
|
|
|
|
|
|
//校验时间格式
|
|
//校验时间格式
|
|
@@ -856,30 +893,75 @@ func (this *CalculateController) BatchEdit() {
|
|
br.Msg = "拼接日期有误,请重新输入"
|
|
br.Msg = "拼接日期有误,请重新输入"
|
|
return
|
|
return
|
|
}
|
|
}
|
|
|
|
+ case utils.DATA_SOURCE_CALCULATE_NHCC: //拟合残差指标
|
|
|
|
+ //指标校验
|
|
|
|
+ if len(req.EdbInfoIdArr) != 2 {
|
|
|
|
+ br.Msg = "选择的指标异常,请重新选择"
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+ fromEdbInfoId = req.EdbInfoIdArr[0].EdbInfoId
|
|
|
|
+
|
|
|
|
+ //校验时间格式
|
|
|
|
+ //数据格式:2022-11-01,2022-11-10
|
|
|
|
+ timeList := strings.Split(req.Formula, ",")
|
|
|
|
+ if len(timeList) != 2 {
|
|
|
|
+ br.Msg = "选择时间有误,请重新输入"
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+ startDate, err := time.ParseInLocation(utils.FormatDate, timeList[0], time.Local)
|
|
|
|
+ if err != nil {
|
|
|
|
+ br.Msg = "开始日期有误,请重新输入"
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+ endDate, err := time.ParseInLocation(utils.FormatDate, timeList[1], time.Local)
|
|
|
|
+ if err != nil {
|
|
|
|
+ br.Msg = "结束日期有误,请重新输入"
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+ if utils.GetTimeSubDay(startDate, endDate) < 2 {
|
|
|
|
+ br.Msg = "日期间隔不得少于两天"
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+ nhccDate.StartDate = startDate
|
|
|
|
+ nhccDate.EndDate = endDate
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // 获取基础指标信息
|
|
|
|
+ fromEdbInfo, err := models.GetEdbInfoById(fromEdbInfoId)
|
|
|
|
+ if err != nil {
|
|
|
|
+ if err.Error() == utils.ErrNoRow() {
|
|
|
|
+ br.Msg = "指标已被删除,请刷新页面"
|
|
|
|
+ br.ErrMsg = "指标已被删除,请刷新页面:Err:" + err.Error()
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+ br.Msg = "获取指标信息失败"
|
|
|
|
+ br.ErrMsg = "获取指标信息失败:Err:" + err.Error()
|
|
|
|
+ return
|
|
}
|
|
}
|
|
|
|
|
|
var sourName string
|
|
var sourName string
|
|
var edbInfoId int
|
|
var edbInfoId int
|
|
|
|
|
|
- if req.Source == utils.DATA_SOURCE_CALCULATE_LJZZY {
|
|
|
|
|
|
+ switch req.Source {
|
|
|
|
+ case utils.DATA_SOURCE_CALCULATE_LJZZY:
|
|
sourName = "累计值转月值"
|
|
sourName = "累计值转月值"
|
|
if fromEdbInfo.Frequency != "月度" {
|
|
if fromEdbInfo.Frequency != "月度" {
|
|
br.Msg = "请选择月度指标"
|
|
br.Msg = "请选择月度指标"
|
|
return
|
|
return
|
|
}
|
|
}
|
|
err = models.EditCalculateLjzzy(edbInfo, &req, fromEdbInfo)
|
|
err = models.EditCalculateLjzzy(edbInfo, &req, fromEdbInfo)
|
|
- } else if req.Source == utils.DATA_SOURCE_CALCULATE_TBZ {
|
|
|
|
|
|
+ case utils.DATA_SOURCE_CALCULATE_TBZ:
|
|
sourName = "同比值"
|
|
sourName = "同比值"
|
|
err = models.EditCalculateTbz(edbInfo, &req, fromEdbInfo)
|
|
err = models.EditCalculateTbz(edbInfo, &req, fromEdbInfo)
|
|
- } else if req.Source == utils.DATA_SOURCE_CALCULATE_TCZ {
|
|
|
|
|
|
+ case utils.DATA_SOURCE_CALCULATE_TCZ:
|
|
fmt.Println("start edit", time.Now())
|
|
fmt.Println("start edit", time.Now())
|
|
sourName = "同差值"
|
|
sourName = "同差值"
|
|
err = models.EditCalculateTcz(edbInfo, &req, fromEdbInfo)
|
|
err = models.EditCalculateTcz(edbInfo, &req, fromEdbInfo)
|
|
fmt.Println("end edit", time.Now())
|
|
fmt.Println("end edit", time.Now())
|
|
- } else if req.Source == utils.DATA_SOURCE_CALCULATE_NSZYDPJJS {
|
|
|
|
|
|
+ case utils.DATA_SOURCE_CALCULATE_NSZYDPJJS:
|
|
sourName = "N数值移动平均计算"
|
|
sourName = "N数值移动平均计算"
|
|
err = models.EditCalculateNszydpjjs(edbInfo, &req, fromEdbInfo, formulaInt, edbInfo.CalculateFormula)
|
|
err = models.EditCalculateNszydpjjs(edbInfo, &req, fromEdbInfo, formulaInt, edbInfo.CalculateFormula)
|
|
- } else if req.Source == utils.DATA_SOURCE_CALCULATE_HBZ {
|
|
|
|
|
|
+ case utils.DATA_SOURCE_CALCULATE_HBZ:
|
|
var condition string
|
|
var condition string
|
|
var pars []interface{}
|
|
var pars []interface{}
|
|
condition += " AND edb_info_id =? "
|
|
condition += " AND edb_info_id =? "
|
|
@@ -898,16 +980,16 @@ func (this *CalculateController) BatchEdit() {
|
|
}
|
|
}
|
|
sourName = "环比值"
|
|
sourName = "环比值"
|
|
err = models.EditCalculateHbz(edbInfo, &req, fromEdbInfo, formulaInt, edbInfo.CalculateFormula)
|
|
err = models.EditCalculateHbz(edbInfo, &req, fromEdbInfo, formulaInt, edbInfo.CalculateFormula)
|
|
- } else if req.Source == utils.DATA_SOURCE_CALCULATE_HCZ {
|
|
|
|
|
|
+ case utils.DATA_SOURCE_CALCULATE_HCZ:
|
|
sourName = "环差值"
|
|
sourName = "环差值"
|
|
err = models.EditCalculateHcz(edbInfo, &req, fromEdbInfo, formulaInt, edbInfo.CalculateFormula)
|
|
err = models.EditCalculateHcz(edbInfo, &req, fromEdbInfo, formulaInt, edbInfo.CalculateFormula)
|
|
- } else if req.Source == utils.DATA_SOURCE_CALCULATE_BP {
|
|
|
|
|
|
+ case utils.DATA_SOURCE_CALCULATE_BP:
|
|
sourName = "变频"
|
|
sourName = "变频"
|
|
err = models.EditCalculateBp(edbInfo, &req, fromEdbInfo)
|
|
err = models.EditCalculateBp(edbInfo, &req, fromEdbInfo)
|
|
- } else if req.Source == utils.DATA_SOURCE_CALCULATE_TIME_SHIFT {
|
|
|
|
|
|
+ case utils.DATA_SOURCE_CALCULATE_TIME_SHIFT:
|
|
sourName = "时间移位"
|
|
sourName = "时间移位"
|
|
err = models.EditCalculateTimeShift(edbInfo, &req, fromEdbInfo)
|
|
err = models.EditCalculateTimeShift(edbInfo, &req, fromEdbInfo)
|
|
- } else if req.Source == utils.DATA_SOURCE_CALCULATE_ZJPJ {
|
|
|
|
|
|
+ case utils.DATA_SOURCE_CALCULATE_ZJPJ:
|
|
sourName = "直接拼接"
|
|
sourName = "直接拼接"
|
|
|
|
|
|
if len(req.EdbInfoIdArr) != 1 {
|
|
if len(req.EdbInfoIdArr) != 1 {
|
|
@@ -930,7 +1012,7 @@ func (this *CalculateController) BatchEdit() {
|
|
return
|
|
return
|
|
}
|
|
}
|
|
err = models.EditCalculateZjpj(&req, edbInfo, fromEdbInfo, secondEdbInfo)
|
|
err = models.EditCalculateZjpj(&req, edbInfo, fromEdbInfo, secondEdbInfo)
|
|
- } else if req.Source == utils.DATA_SOURCE_CALCULATE_LJZTBPJ { //累计值同比拼接
|
|
|
|
|
|
+ case utils.DATA_SOURCE_CALCULATE_LJZTBPJ: //累计值同比拼接
|
|
sourName = "累计值同比拼接"
|
|
sourName = "累计值同比拼接"
|
|
|
|
|
|
if fromEdbInfo.Frequency != "月度" {
|
|
if fromEdbInfo.Frequency != "月度" {
|
|
@@ -968,14 +1050,30 @@ func (this *CalculateController) BatchEdit() {
|
|
return
|
|
return
|
|
}
|
|
}
|
|
err = models.EditCalculateLjztbpj(&req, edbInfo, fromEdbInfo, tbzEdbInfo)
|
|
err = models.EditCalculateLjztbpj(&req, edbInfo, fromEdbInfo, tbzEdbInfo)
|
|
-
|
|
|
|
- } else if req.Source == utils.DATA_SOURCE_CALCULATE_CJJX {
|
|
|
|
|
|
+ case utils.DATA_SOURCE_CALCULATE_CJJX:
|
|
sourName = "超季节性"
|
|
sourName = "超季节性"
|
|
err = models.EditCalculateCjjx(&req, edbInfo, fromEdbInfo, formulaInt)
|
|
err = models.EditCalculateCjjx(&req, edbInfo, fromEdbInfo, formulaInt)
|
|
- } else {
|
|
|
|
|
|
+ case utils.DATA_SOURCE_CALCULATE_NHCC:
|
|
|
|
+ sourName = "拟合残差"
|
|
|
|
+ secondEdbInfoReq := req.EdbInfoIdArr[1]
|
|
|
|
+ secondEdbInfo, err := models.GetEdbInfoById(secondEdbInfoReq.EdbInfoId)
|
|
|
|
+ if err != nil {
|
|
|
|
+ br.Msg = "获取因变量的指标信息失败"
|
|
|
|
+ br.ErrMsg = "获取因变量的指标信息失败:Err:" + err.Error()
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if fromEdbInfo.EdbInfoId == secondEdbInfo.EdbInfoId {
|
|
|
|
+ br.Msg = "两个指标不允许为同一个"
|
|
|
|
+ br.ErrMsg = "两个指标不允许为同一个"
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+ err = models.EditCalculateNhcc(&req, edbInfo, fromEdbInfo, secondEdbInfo, nhccDate)
|
|
|
|
+ default:
|
|
br.Msg = "无效计算方式"
|
|
br.Msg = "无效计算方式"
|
|
br.ErrMsg = "无效计算方式,source:" + strconv.Itoa(req.Source)
|
|
br.ErrMsg = "无效计算方式,source:" + strconv.Itoa(req.Source)
|
|
return
|
|
return
|
|
|
|
+
|
|
}
|
|
}
|
|
if err != nil {
|
|
if err != nil {
|
|
br.Msg = "生成" + sourName + "失败"
|
|
br.Msg = "生成" + sourName + "失败"
|
|
@@ -1311,6 +1409,12 @@ func (this *CalculateController) Refresh() {
|
|
errMsg = "RefreshAllCalculateCjjx Err:" + err.Error()
|
|
errMsg = "RefreshAllCalculateCjjx Err:" + err.Error()
|
|
break
|
|
break
|
|
}
|
|
}
|
|
|
|
+ case utils.DATA_SOURCE_CALCULATE_NHCC: //nhcc
|
|
|
|
+ err = models.RefreshAllCalculateNhcc(edbInfo)
|
|
|
|
+ if err != nil && err.Error() != utils.ErrNoRow() {
|
|
|
|
+ errMsg = "RefreshAllCalculateNhcc Err:" + err.Error()
|
|
|
|
+ break
|
|
|
|
+ }
|
|
|
|
|
|
default:
|
|
default:
|
|
br.Msg = "来源异常,请联系相关开发!"
|
|
br.Msg = "来源异常,请联系相关开发!"
|